corso/src/internal/tester/storage.go
Keepers 76b3fe3b86
append ToCore to all errors tests (#2793)
In order to retrieve all clues structured error data in tests, we need to extract it from the error using the clues library.

This change appends `clues.ToCore(err)` to all
variations of `assert.NoError(t, err)`.  The only
other changes are those necessary to preserve
linting, or to produce an error variable for the
ToCore call.

---

#### Does this PR need a docs update or release note?

- [x]  No

#### Type of change

- [x] 🤖 Test
- [x] 🧹 Tech Debt/Cleanup

#### Issue(s)

* #1970

#### Test Plan

- [x]  Unit test
- [x] 💚 E2E
2023-03-15 19:02:47 +00:00

51 lines
1.4 KiB
Go

package tester
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/alcionai/clues"
"github.com/alcionai/corso/src/pkg/credentials"
"github.com/alcionai/corso/src/pkg/storage"
)
const testRepoRootPrefix = "corso_integration_test/"
var AWSStorageCredEnvs = []string{
credentials.AWSAccessKeyID,
credentials.AWSSecretAccessKey,
credentials.AWSSessionToken,
}
// NewPrefixedS3Storage returns a storage.Storage object initialized with environment
// variables used for integration tests that use S3. The prefix for the storage
// path will be unique.
// Uses t.TempDir() to generate a unique config storage and caching directory for this
// test. Suites that need to identify this value can retrieve it again from the common
// configs.
func NewPrefixedS3Storage(t *testing.T) storage.Storage {
now := LogTimeOfTest(t)
cfg, err := readTestConfig()
require.NoError(t, err, "configuring storage from test file", clues.ToCore(err))
prefix := testRepoRootPrefix + t.Name() + "-" + now
t.Logf("testing at s3 bucket [%s] prefix [%s]", cfg[TestCfgBucket], prefix)
st, err := storage.NewStorage(
storage.ProviderS3,
storage.S3Config{
Bucket: cfg[TestCfgBucket],
Prefix: prefix,
},
storage.CommonConfig{
Corso: credentials.GetCorso(),
KopiaCfgDir: t.TempDir(),
},
)
require.NoError(t, err, "creating storage", clues.ToCore(err))
return st
}