|
1 | 1 | package validate |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "os" |
4 | 5 | "testing" |
5 | 6 |
|
6 | 7 | "go.lsp.dev/protocol" |
@@ -69,3 +70,40 @@ workflows: |
69 | 70 |
|
70 | 71 | CheckYamlErrors(t, testCases) |
71 | 72 | } |
| 73 | + |
| 74 | +func TestYamlDocument_parseCheckout(t *testing.T) { |
| 75 | + validConfigFilePath := "./testdata/valid_checkout_method.yml" |
| 76 | + validConfig, err := os.ReadFile(validConfigFilePath) |
| 77 | + if err != nil { |
| 78 | + t.Fatal("Failed to read valid_checkout_method.yml") |
| 79 | + } |
| 80 | + |
| 81 | + invalidConfigFilePath := "./testdata/invalid_checkout_method.yml" |
| 82 | + invalidConfig, err := os.ReadFile(invalidConfigFilePath) |
| 83 | + if err != nil { |
| 84 | + t.Fatal("Failed to read invalid_checkout_method.yml") |
| 85 | + } |
| 86 | + |
| 87 | + testCases := []ValidateTestCase{ |
| 88 | + { |
| 89 | + Name: "Specifying checkout method full does not result in an error", |
| 90 | + YamlContent: string(validConfig), |
| 91 | + Diagnostics: []protocol.Diagnostic{}, |
| 92 | + }, |
| 93 | + { |
| 94 | + Name: "Specifying an invalid checkout method results in an error", |
| 95 | + YamlContent: string(invalidConfig), |
| 96 | + Diagnostics: []protocol.Diagnostic{ |
| 97 | + { |
| 98 | + Severity: protocol.DiagnosticSeverityError, |
| 99 | + Range: protocol.Range{ |
| 100 | + Start: protocol.Position{Line: 7, Character: 8}, |
| 101 | + End: protocol.Position{Line: 7, Character: 16}, |
| 102 | + }, |
| 103 | + Message: "Checkout method 'invalid' is invalid", |
| 104 | + }, |
| 105 | + }, |
| 106 | + }, |
| 107 | + } |
| 108 | + CheckYamlErrors(t, testCases) |
| 109 | +} |
0 commit comments