Skip to content

Commit

Permalink
Use const values in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KsaweryZietara committed Sep 26, 2024
1 parent ddb01c1 commit a5a06f1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/broker/bind_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type User struct {
} `yaml:"user"`
}

const expirationSeconds = 10000

func TestCreateBindingEndpoint(t *testing.T) {
t.Log("test create binding endpoint")

Expand Down Expand Up @@ -151,7 +153,7 @@ func TestCreateBindingEndpoint(t *testing.T) {
BindablePlans: EnablePlans{
fixture.PlanName,
},
ExpirationSeconds: 10000,
ExpirationSeconds: expirationSeconds,
}

//// api handler
Expand Down Expand Up @@ -191,7 +193,7 @@ func TestCreateBindingEndpoint(t *testing.T) {

duration, err := getTokenDuration(t, binding.Credentials)
require.NoError(t, err)
assert.Equal(t, 10000*time.Second, duration)
assert.Equal(t, expirationSeconds*time.Second, duration)

//// verify connectivity using kubeconfig from the generated binding
newClient := kubeconfigClient(t, binding.Credentials.(string))
Expand All @@ -207,22 +209,23 @@ func TestCreateBindingEndpoint(t *testing.T) {
})

t.Run("should create a new service binding with custom token expiration time", func(t *testing.T) {
const customExpirationSeconds = 900

// When
response := CallAPI(httpServer, method, "v2/service_instances/1/service_bindings/binding-id2?accepts_incomplete=true", fmt.Sprintf(`{
"service_id": "123",
"plan_id": "%s",
"parameters": {
"token_request": true,
"expiration_seconds": 900
"expiration_seconds": %v
}
}`, fixture.PlanId), t)
}`, fixture.PlanId, customExpirationSeconds), t)

binding := verifyResponse(t, response)

duration, err := getTokenDuration(t, binding.Credentials)
require.NoError(t, err)
assert.Equal(t, 900*time.Second, duration)
assert.Equal(t, customExpirationSeconds*time.Second, duration)
})
}

Expand Down

0 comments on commit a5a06f1

Please sign in to comment.