importBlock returns just the prefix before the first declaration, which is where Serialize emits the merged imports.
(t *testing.T, output string)
| 36 | // importBlock returns just the prefix before the first declaration, which is |
| 37 | // where Serialize emits the merged imports. |
| 38 | func importBlock(t *testing.T, output string) string { |
| 39 | t.Helper() |
| 40 | require.True(t, strings.HasPrefix(output, "// Code generated by 'guts'. DO NOT EDIT."), |
| 41 | "output must start with the generated header, got %q", output) |
| 42 | end := strings.Index(output, "interface ") |
| 43 | if end < 0 { |
| 44 | end = len(output) |
| 45 | } |
| 46 | return output[:end] |
| 47 | } |
| 48 | |
| 49 | // TestInjectImport_Merge proves that repeated InjectImport calls for the same |
| 50 | // module collapse into a single statement and that specifiers are sorted by |
no outgoing calls
no test coverage detected
searching dependent graphs…