Skip to content

Commit 02ddd75

Browse files
authored
test/kubernetes/endpoints_test.go: fail test on no result to avoid panic (#173)
* test/kubernetes/endpoints_test.go: fail test on no result to avoid panic Otherwise following assertions will panic when result is nil. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com> * test: fix CircleCI builds Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com> --------- Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
1 parent baaf458 commit 02ddd75

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

test/k8sdeployment/configmap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ my.cluster.local:53 {
7373
}
7474

7575
if strings.Compare(corefileTranslated, corefileExpected) != 0 {
76-
t.Fatalf("failed test: Translation does not match.\nGOT:\n" + corefileTranslated + "\n\nEXPECTED:\n" + corefileExpected)
76+
t.Fatalf("failed test: Translation does not match.\nGOT:\n%s\n\nEXPECTED:\n%s", corefileTranslated, corefileExpected)
7777
}
7878

7979
// Clean-up by removing kube-dns ConfigMap

test/kubernetai/autopath_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ var autopathTests = []test.Case{
7979
}
8080

8181
func TestKubernetesAutopath(t *testing.T) {
82-
8382
// set up server to handle internal zone, to trap *.internal search path in travis environment.
8483
internal := `; internal zone info for autopath tests
8584
internal. IN SOA sns.internal. noc.internal. 2015082541 7200 3600 1209600 3600
@@ -88,8 +87,7 @@ internal. IN SOA sns.internal. noc.internal. 2015082541 7200 3600 1209600 3600
8887
defer upstream.Stop()
8988
defer rmFunc()
9089

91-
corefile :=
92-
` .:53 {
90+
corefile := ` .:53 {
9391
health
9492
ready
9593
errors
@@ -126,7 +124,7 @@ internal. IN SOA sns.internal. noc.internal. 2015082541 7200 3600 1209600 3600
126124
}
127125
err = kubernetes.WaitForClientPodRecord(namespace)
128126
if err != nil {
129-
t.Fatalf(err.Error())
127+
t.Fatal(err.Error())
130128
}
131129

132130
for _, tc := range testCases {

test/kubernetes/endpoints_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestKubernetesEndpointPodNames(t *testing.T) {
5757
t.Run(fmt.Sprintf("%s %s", expected.Qname, dns.TypeToString[expected.Qtype]), func(t *testing.T) {
5858
result, err := DoIntegrationTest(expected.Case, namespace)
5959
if err != nil {
60-
t.Error(err.Error())
60+
t.Fatal(err.Error())
6161
}
6262

6363
if len(result.Answer) != expected.AnswerCount {

0 commit comments

Comments
 (0)