Skip to content

Commit fdf340f

Browse files
authored
add test for missing numerator case (#3715)
1 parent 0cd7d7f commit fdf340f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

internal/controller/state/dataplane/convert_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,25 @@ func TestConvertHTTPMirrorFilter(t *testing.T) {
397397
Target: helpers.GetPointer("/_ngf-internal-mirror-namespace/backend-test/route1-0"),
398398
Percent: helpers.GetPointer(float64(100)),
399399
},
400-
name: "numerator equals denominator",
400+
name: "100% mirroring if numerator equals denominator",
401+
},
402+
{
403+
filter: &v1.HTTPRequestMirrorFilter{
404+
BackendRef: v1.BackendObjectReference{
405+
Name: "backend",
406+
Namespace: helpers.GetPointer[v1.Namespace]("namespace"),
407+
},
408+
Fraction: &v1.Fraction{
409+
Denominator: helpers.GetPointer(int32(2)),
410+
},
411+
},
412+
expected: &HTTPRequestMirrorFilter{
413+
Name: helpers.GetPointer("backend"),
414+
Namespace: helpers.GetPointer("namespace"),
415+
Target: helpers.GetPointer("/_ngf-internal-mirror-namespace/backend-test/route1-0"),
416+
Percent: helpers.GetPointer(float64(0)),
417+
},
418+
name: "0% mirroring if numerator is not specified",
401419
},
402420
{
403421
filter: &v1.HTTPRequestMirrorFilter{

0 commit comments

Comments
 (0)