github.com/cycloidio/terraform@v1.1.10-0.20220513142504-76d5c768dc63/addrs/module_test.go (about) 1 package addrs 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func TestModuleEqual_true(t *testing.T) { 9 modules := []Module{ 10 RootModule, 11 {"a"}, 12 {"a", "b"}, 13 {"a", "b", "c"}, 14 } 15 for _, m := range modules { 16 t.Run(m.String(), func(t *testing.T) { 17 if !m.Equal(m) { 18 t.Fatalf("expected %#v to be equal to itself", m) 19 } 20 }) 21 } 22 } 23 24 func TestModuleEqual_false(t *testing.T) { 25 testCases := []struct { 26 left Module 27 right Module 28 }{ 29 { 30 RootModule, 31 Module{"a"}, 32 }, 33 { 34 Module{"a"}, 35 Module{"b"}, 36 }, 37 { 38 Module{"a"}, 39 Module{"a", "a"}, 40 }, 41 { 42 Module{"a", "b"}, 43 Module{"a", "B"}, 44 }, 45 } 46 for _, tc := range testCases { 47 t.Run(fmt.Sprintf("%s = %s", tc.left, tc.right), func(t *testing.T) { 48 if tc.left.Equal(tc.right) { 49 t.Fatalf("expected %#v not to be equal to %#v", tc.left, tc.right) 50 } 51 52 if tc.right.Equal(tc.left) { 53 t.Fatalf("expected %#v not to be equal to %#v", tc.right, tc.left) 54 } 55 }) 56 } 57 }