(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func TestSourceNamesForAlias(t *testing.T) { |
| 101 | tests := []struct { |
| 102 | alias string |
| 103 | sources []string |
| 104 | err error |
| 105 | }{ |
| 106 | // no such definition exists |
| 107 | { |
| 108 | alias: "x", |
| 109 | sources: []string(nil), |
| 110 | }, |
| 111 | // not an alias |
| 112 | { |
| 113 | alias: "i1", |
| 114 | sources: []string(nil), |
| 115 | }, |
| 116 | // alias to 1 |
| 117 | { |
| 118 | alias: "a1", |
| 119 | sources: []string{"s1"}, |
| 120 | }, |
| 121 | // alias to multiple |
| 122 | { |
| 123 | alias: "a2", |
| 124 | sources: []string{"s1", "s2"}, |
| 125 | }, |
| 126 | // alias to another alias and index |
| 127 | { |
| 128 | alias: "a3", |
| 129 | sources: []string{"s1", "s2"}, |
| 130 | }, |
| 131 | // alias with loop |
| 132 | { |
| 133 | alias: "a4", |
| 134 | err: errAliasExpansionTooDeep, |
| 135 | }, |
| 136 | // alias to a single index |
| 137 | { |
| 138 | alias: "a5", |
| 139 | sources: []string{"bucket1:scope1:collection1"}, |
| 140 | }, |
| 141 | // alias to a single multi-collection index |
| 142 | { |
| 143 | alias: "a6", |
| 144 | sources: []string{"bucket2:scope1:collection1", "bucket2:scope1:collection2", |
| 145 | "bucket2:scope1:collection3"}, |
| 146 | }, |
| 147 | // alias to a single multi-collection index and nested alias |
| 148 | { |
| 149 | alias: "a7", |
| 150 | sources: []string{"bucket2:scope1:collection1", "bucket2:scope1:collection2", |
| 151 | "bucket2:scope1:collection3", "s1", "s2"}, |
| 152 | }, |
| 153 | } |
| 154 | |
| 155 | for i, test := range tests { |
| 156 | actualNames, err := sourceNamesForAlias(test.alias, testIndexDefsByName, 0) |
| 157 | if err != test.err { |
nothing calls this directly
no test coverage detected