(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestGetGoDirective(t *testing.T) { |
| 29 | tests := []struct { |
| 30 | name string |
| 31 | input []byte |
| 32 | expected string |
| 33 | }{ |
| 34 | { |
| 35 | name: "normal go directive", |
| 36 | input: []byte("module github.com/voidint/g\n\ngo 1.20\n"), |
| 37 | expected: "1.20", |
| 38 | }, |
| 39 | { |
| 40 | name: "normal go directive", |
| 41 | input: []byte("module github.com/voidint/g\n\ngo 1.24.0\n"), |
| 42 | expected: "1.24.0", |
| 43 | }, |
| 44 | { |
| 45 | name: "normal go directive", |
| 46 | input: []byte("module github.com/voidint/g\n\ngo 1.24.4\n"), |
| 47 | expected: "1.24.4", |
| 48 | }, |
| 49 | { |
| 50 | name: "normal go directive", |
| 51 | input: []byte("module github.com/voidint/g\n\ngo 1.25rc1\n"), |
| 52 | expected: "1.25rc1", |
| 53 | }, |
| 54 | { |
| 55 | name: "no go directive", |
| 56 | input: []byte("module github.com/voidint/g\n"), |
| 57 | expected: "", |
| 58 | }, |
| 59 | { |
| 60 | name: "malformed directive", |
| 61 | input: []byte("go1.20"), |
| 62 | expected: "", |
| 63 | }, |
| 64 | { |
| 65 | name: "empty input", |
| 66 | input: []byte(""), |
| 67 | expected: "", |
| 68 | }, |
| 69 | } |
| 70 | |
| 71 | for _, tt := range tests { |
| 72 | t.Run(tt.name, func(t *testing.T) { |
| 73 | got := getGoDirective(tt.input) |
| 74 | assert.Equal(t, tt.expected, got) |
| 75 | }) |
| 76 | } |
| 77 | } |
nothing calls this directly
no test coverage detected