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