Skip to content

Commit eda974b

Browse files
committed
WIP - invalid case for adding VSR
1 parent ecd5c62 commit eda974b

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

internal/k8s/configuration_vsr_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,45 @@ func TestAddVirtualServer_InvalidVS(t *testing.T) {
155155
t.Parallel()
156156
}
157157

158+
// Negative flow - User attempts to add VSR to not existing VS
159+
func TestAttemptToAddVSRtoNotExistingVS_ReturnsProblems(t *testing.T) {
160+
t.Parallel()
161+
162+
configuration := createTestConfiguration()
163+
164+
labels := make(map[string]string)
165+
vsr := createTestVirtualServerRoute("virtualserverroute", "foo.example.com", "/first", labels)
166+
167+
// Try to add VirtualServerRoute
168+
169+
var expectedChanges []ResourceChange
170+
expectedProblems := []ConfigurationProblem{
171+
{
172+
Object: vsr,
173+
Reason: "NoVirtualServerFound",
174+
Message: "VirtualServer is invalid or doesn't exist",
175+
},
176+
}
177+
178+
changes, problems := configuration.AddOrUpdateVirtualServerRoute(vsr)
179+
if !cmp.Equal(expectedChanges, changes) {
180+
t.Error(cmp.Diff(expectedChanges, changes))
181+
}
182+
if !cmp.Equal(expectedProblems, problems) {
183+
t.Error(cmp.Diff(expectedProblems, problems))
184+
}
185+
}
186+
158187
// WIP - Jakub
159188
// TODO: vsr route selector test
160189
func TestAddVirtualServerWithVirtualServerRoutesVSR(t *testing.T) {
161190
configuration := createTestConfiguration()
162191

163192
// Add VirtualServerRoute-1
164193

165-
vsr1 := createTestVirtualServerRoute("virtualserverroute-1", "foo.example.com", "/first", nil)
194+
labels := make(map[string]string)
195+
vsr1 := createTestVirtualServerRoute("virtualserverroute-1", "foo.example.com", "/first", labels)
196+
166197
var expectedChanges []ResourceChange
167198
expectedProblems := []ConfigurationProblem{
168199
{

0 commit comments

Comments
 (0)