...
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ipset
15
16 import (
17 "testing"
18
19 . "github.com/onsi/gomega"
20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
22 "github.com/chaos-mesh/chaos-mesh/api/v1alpha1"
23 )
24
25 func Test_generateIPSetName(t *testing.T) {
26 g := NewWithT(t)
27 postfix := "alongpostfix"
28
29 t.Run("name with postfix", func(t *testing.T) {
30 chaosName := "test"
31
32 networkChaos := &v1alpha1.NetworkChaos{
33 ObjectMeta: metav1.ObjectMeta{
34 Name: chaosName,
35 },
36 }
37
38 name := GenerateIPSetName(networkChaos, postfix)
39
40 g.Expect(name).Should(Equal(chaosName + "_" + postfix))
41 })
42
43 t.Run("length equal 27", func(t *testing.T) {
44 networkChaos := &v1alpha1.NetworkChaos{
45 ObjectMeta: metav1.ObjectMeta{
46 Name: "test-metav1object",
47 },
48 }
49
50 name := GenerateIPSetName(networkChaos, postfix)
51
52 g.Expect(len(name)).Should(Equal(27))
53 })
54 }
55