package console import ( "context" "fmt" "testing" "github.com/carlosframework/platform/internal/release" ) // s3ShapedStore wraps Get's errors the way S3Store does. type s3ShapedStore struct{ release.Store } func (s s3ShapedStore) Get(ctx context.Context, key string) ([]byte, string, error) { b, etag, err := s.Store.Get(ctx, key) if err != nil { return nil, "", fmt.Errorf("s3store: %s: %w", key, err) } return b, etag, nil } func TestPutHostReportCreatesThroughAWrappedNotFound(t *testing.T) { ctx := t.Context() store := s3ShapedStore{release.NewDirStore(t.TempDir())} const key = "status/consoles/console-2.json" for _, body := range []string{`{"n":1}`, `{"n":2}`} { if err := putHostReport(ctx, store, key, []byte(body)); err != nil { t.Fatalf("put %s: %v", body, err) } got, _, err := store.Get(ctx, key) if err != nil || string(got) != body { t.Fatalf("stored %q, %v; want %s", got, err, body) } } }