Download this file
| 1 | package lease |
| 2 | |
| 3 | import ( |
| 4 | "github.com/carlosframework/platform/internal/release" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestExecutionStoreUsesExistingConditionalTransport(t *testing.T) { |
| 9 | t.Setenv("AWS_ACCESS_KEY_ID", "test") |
| 10 | t.Setenv("AWS_SECRET_ACCESS_KEY", "test") |
| 11 | t.Setenv("AWS_EC2_METADATA_DISABLED", "true") |
| 12 | t.Setenv("AWS_CONFIG_FILE", t.TempDir()+"/absent") |
| 13 | t.Setenv("AWS_SHARED_CREDENTIALS_FILE", t.TempDir()+"/absent") |
| 14 | t.Setenv("CARLOS_S3_ENDPOINT", "https://objects.invalid") |
| 15 | if _, err := ExecutionStore(t.Context(), "", "eu-west-1"); err == nil { |
| 16 | t.Fatal("empty bucket accepted") |
| 17 | } |
| 18 | store, err := ExecutionStore(t.Context(), "control", "eu-west-1") |
| 19 | if err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | s, ok := store.(*release.S3Store) |
| 23 | if !ok || s.Bucket != "control" { |
| 24 | t.Fatal("wrong store") |
| 25 | } |
| 26 | opts := s.Client.Options() |
| 27 | if opts.Region != "eu-west-1" || opts.BaseEndpoint == nil || *opts.BaseEndpoint != "https://objects.invalid" || !opts.UsePathStyle { |
| 28 | t.Fatalf("lost leaser configuration: %+v", opts) |
| 29 | } |
| 30 | if _, ok := store.(release.ConditionalDeleter); !ok { |
| 31 | t.Fatal("no conditional release") |
| 32 | } |
| 33 | } |
| 34 | |