Skip to content

Commit

Permalink
Use assertion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanslade committed Jan 15, 2024
1 parent 8f9f7bd commit 3670498
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions xata/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,26 +203,17 @@ func Test_loadDatabaseConfig_with_envvars(t *testing.T) {
}

// with branch and region env vars
t.Run("load config from XATA_WORKSPACE_ID, regionEnvVar and XATA_BRANCH env vars", func(t *testing.T) {
t.Run("load config from XATA_WORKSPACE_ID, XATA_REGION and XATA_BRANCH env vars", func(t *testing.T) {
dbCfg, err := loadDatabaseConfig()
if err != nil {
t.Fatalf("Error loading config: %v", err)
}

if dbCfg.workspaceID != setWsId {
t.Fatalf("Expected Workspace ID: %s, got: %s", setWsId, dbCfg.workspaceID)
}
if dbCfg.branchName != setBranch {
t.Fatalf("Expected branch name: %s, got: %s", setBranch, dbCfg.branchName)
}
if dbCfg.region != setRegion {
t.Fatalf("Expected region: %s, got: %s", setRegion, dbCfg.region)
}
assert.NoError(t, err)
assert.Equal(t, setWsId, dbCfg.workspaceID)
assert.Equal(t, setBranch, dbCfg.branchName)
assert.Equal(t, setRegion, dbCfg.region)
})

t.Cleanup(func() {
os.Unsetenv(EnvXataWorkspaceID)
os.Unsetenv(EnvXataBranch)
os.Unsetenv(EnvXataRegion)
assert.NoError(t, os.Unsetenv(EnvXataWorkspaceID))
assert.NoError(t, os.Unsetenv(EnvXataBranch))
assert.NoError(t, os.Unsetenv(EnvXataRegion))
})
}

0 comments on commit 3670498

Please sign in to comment.