37 lines
909 B
Go
Raw Normal View History

2024-06-13 10:13:32 +00:00
package errors_test
import (
"path/filepath"
"strings"
"testing"
"git.akyoto.dev/cli/q/src/build"
"git.akyoto.dev/cli/q/src/errors"
"git.akyoto.dev/go/assert"
)
func TestErrors(t *testing.T) {
tests := []struct {
File string
ExpectedError error
}{
{"ExpectedFunctionDefinition.q", errors.ExpectedFunctionDefinition},
2024-06-14 07:23:21 +00:00
{"ExpectedFunctionParameters.q", errors.ExpectedFunctionParameters},
{"MissingBlockEnd.q", errors.MissingBlockEnd},
{"MissingBlockStart.q", errors.MissingBlockStart},
{"MissingGroupEnd.q", errors.MissingGroupEnd},
{"MissingGroupStart.q", errors.MissingGroupStart},
2024-06-13 10:13:32 +00:00
}
for _, test := range tests {
name := strings.TrimSuffix(test.File, ".q")
t.Run(name, func(t *testing.T) {
b := build.New(filepath.Join("testdata", test.File))
_, err := b.Run()
assert.NotNil(t, err)
assert.Contains(t, err.Error(), test.ExpectedError.Error())
})
}
}