-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move binding createdBy tests (#1356)
* Move binding createdBy tests * wip
- Loading branch information
1 parent
c7b718b
commit dc87347
Showing
2 changed files
with
60 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -513,59 +513,6 @@ func assertServiceAccountsNotExists(t *testing.T, k8sClient client.Client, bindi | |
assert.True(t, apierrors.IsNotFound(err)) | ||
} | ||
|
||
func TestCreatedBy(t *testing.T) { | ||
emptyStr := "" | ||
email := "[email protected]" | ||
origin := "origin" | ||
tests := []struct { | ||
name string | ||
context broker.BindingContext | ||
expected string | ||
}{ | ||
{ | ||
name: "Both Email and Origin are nil", | ||
context: broker.BindingContext{Email: nil, Origin: nil}, | ||
expected: "", | ||
}, | ||
{ | ||
name: "Both Email and Origin are empty", | ||
context: broker.BindingContext{Email: &emptyStr, Origin: &emptyStr}, | ||
expected: "", | ||
}, | ||
{ | ||
name: "Origin is nil", | ||
context: broker.BindingContext{Email: &email, Origin: nil}, | ||
expected: "[email protected]", | ||
}, | ||
{ | ||
name: "Origin is empty", | ||
context: broker.BindingContext{Email: &email, Origin: &emptyStr}, | ||
expected: "[email protected]", | ||
}, | ||
{ | ||
name: "Email is nil", | ||
context: broker.BindingContext{Email: nil, Origin: &origin}, | ||
expected: "origin", | ||
}, | ||
{ | ||
name: "Email is empty", | ||
context: broker.BindingContext{Email: &emptyStr, Origin: &origin}, | ||
expected: "origin", | ||
}, | ||
{ | ||
name: "Both Email and Origin are set", | ||
context: broker.BindingContext{Email: &email, Origin: &origin}, | ||
expected: "[email protected]", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.expected, tt.context.CreatedBy()) | ||
}) | ||
} | ||
} | ||
|
||
func assertExistsAndKubeconfigCreated(t *testing.T, actual domain.Binding, bindingID, instanceID string, httpServer *httptest.Server, db storage.BrokerStorage) { | ||
expected, err := db.Bindings().Get(instanceID, bindingID) | ||
require.NoError(t, err) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package broker | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCreatedBy(t *testing.T) { | ||
emptyStr := "" | ||
email := "[email protected]" | ||
origin := "origin" | ||
tests := []struct { | ||
name string | ||
context BindingContext | ||
expected string | ||
}{ | ||
{ | ||
name: "Both Email and Origin are nil", | ||
context: BindingContext{Email: nil, Origin: nil}, | ||
expected: "", | ||
}, | ||
{ | ||
name: "Both Email and Origin are empty", | ||
context: BindingContext{Email: &emptyStr, Origin: &emptyStr}, | ||
expected: "", | ||
}, | ||
{ | ||
name: "Origin is nil", | ||
context: BindingContext{Email: &email, Origin: nil}, | ||
expected: "[email protected]", | ||
}, | ||
{ | ||
name: "Origin is empty", | ||
context: BindingContext{Email: &email, Origin: &emptyStr}, | ||
expected: "[email protected]", | ||
}, | ||
{ | ||
name: "Email is nil", | ||
context: BindingContext{Email: nil, Origin: &origin}, | ||
expected: "origin", | ||
}, | ||
{ | ||
name: "Email is empty", | ||
context: BindingContext{Email: &emptyStr, Origin: &origin}, | ||
expected: "origin", | ||
}, | ||
{ | ||
name: "Both Email and Origin are set", | ||
context: BindingContext{Email: &email, Origin: &origin}, | ||
expected: "[email protected]", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.expected, tt.context.CreatedBy()) | ||
}) | ||
} | ||
} |