| 85 | } |
| 86 | |
| 87 | func TestModuleID(t *testing.T) { |
| 88 | for i, tc := range []struct { |
| 89 | input ModuleID |
| 90 | expectNamespace string |
| 91 | expectName string |
| 92 | }{ |
| 93 | { |
| 94 | input: "foo", |
| 95 | expectNamespace: "", |
| 96 | expectName: "foo", |
| 97 | }, |
| 98 | { |
| 99 | input: "foo.bar", |
| 100 | expectNamespace: "foo", |
| 101 | expectName: "bar", |
| 102 | }, |
| 103 | { |
| 104 | input: "a.b.c", |
| 105 | expectNamespace: "a.b", |
| 106 | expectName: "c", |
| 107 | }, |
| 108 | } { |
| 109 | actualNamespace := tc.input.Namespace() |
| 110 | if actualNamespace != tc.expectNamespace { |
| 111 | t.Errorf("Test %d: Expected namespace '%s' but got '%s'", i, tc.expectNamespace, actualNamespace) |
| 112 | } |
| 113 | actualName := tc.input.Name() |
| 114 | if actualName != tc.expectName { |
| 115 | t.Errorf("Test %d: Expected name '%s' but got '%s'", i, tc.expectName, actualName) |
| 116 | } |
| 117 | } |
| 118 | } |