Skip to content

Commit

Permalink
Ensure archiving is disabled when CLOUD_ARCHIVING_ENABLED is set to f…
Browse files Browse the repository at this point in the history
…alse
  • Loading branch information
davissp14 committed Jun 25, 2024
1 parent b859216 commit 83eb958
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions internal/flypg/pg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,45 @@ func TestPGConfigInitialization(t *testing.T) {
t.Fatalf("expected %s, got %s", expected, cfg["archive_command"])
}
})

t.Run("cloud-archiving-disabled", func(t *testing.T) {
t.Setenv("CLOUD_ARCHIVING_ENABLED", "true")
t.Setenv("AWS_ACCESS_KEY_ID", "my-key")
t.Setenv("AWS_ENDPOINT_URL", "https://fly.storage.tigris.dev")
t.Setenv("AWS_SECRET_ACCESS_KEY", "my-secret")
t.Setenv("AWS_BUCKET_NAME", "my-bucket")

store, _ := state.NewStore()

if err := pgConf.initialize(store); err != nil {
t.Fatal(err)
}

cfg, err := pgConf.CurrentConfig()
if err != nil {
t.Fatal(err)
}

if cfg["archive_mode"] != "on" {
t.Fatalf("expected archive_mode to be on, got %v", cfg["archive_mode"])
}

t.Setenv("CLOUD_ARCHIVING_ENABLED", "false")

if err := pgConf.initialize(store); err != nil {
t.Fatal(err)
}

cfg, err = pgConf.CurrentConfig()
if err != nil {
t.Fatal(err)
}

if cfg["archive_mode"] != "off" {
t.Fatalf("expected archive_mode to be off, got %v", cfg["archive_mode"])
}

})
}

func TestPGUserConfigOverride(t *testing.T) {
Expand Down

0 comments on commit 83eb958

Please sign in to comment.