* Fix wsl lint errors in pkg package * Fix wsl lint errors in most of internal package Leave some sub-packages out that have higher churn at the moment.
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package tester
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/alcionai/corso/pkg/credentials"
|
|
"github.com/alcionai/corso/pkg/storage"
|
|
)
|
|
|
|
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")
|
|
|
|
st, err := storage.NewStorage(
|
|
storage.ProviderS3,
|
|
storage.S3Config{
|
|
AWS: credentials.GetAWS(nil),
|
|
Bucket: cfg[TestCfgBucket],
|
|
Prefix: t.Name() + "-" + now,
|
|
},
|
|
storage.CommonConfig{
|
|
Corso: credentials.GetCorso(),
|
|
KopiaCfgDir: t.TempDir(),
|
|
},
|
|
)
|
|
require.NoError(t, err, "creating storage")
|
|
|
|
return st
|
|
}
|