Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
238ac5e7
"docs/vscode:/vscode.git/clone" did not exist on "ba87c1607cae2ae00ab2547e911a101ed27ea18b"
Unverified
Commit
238ac5e7
authored
Jan 05, 2024
by
Patrick Devine
Committed by
GitHub
Jan 05, 2024
Browse files
Add unit tests for Parser (#1815)
parent
4f4980b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
parser/parser_test.go
parser/parser_test.go
+63
-0
No files found.
parser/parser_test.go
0 → 100644
View file @
238ac5e7
package
parser
import
(
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func
Test_Parser
(
t
*
testing
.
T
)
{
input
:=
`
FROM model1
ADAPTER adapter1
LICENSE MIT
PARAMETER param1 value1
PARAMETER param2 value2
TEMPLATE template1
`
reader
:=
strings
.
NewReader
(
input
)
commands
,
err
:=
Parse
(
reader
)
assert
.
Nil
(
t
,
err
)
expectedCommands
:=
[]
Command
{
{
Name
:
"model"
,
Args
:
"model1"
},
{
Name
:
"adapter"
,
Args
:
"adapter1"
},
{
Name
:
"license"
,
Args
:
"MIT"
},
{
Name
:
"param1"
,
Args
:
"value1"
},
{
Name
:
"param2"
,
Args
:
"value2"
},
{
Name
:
"template"
,
Args
:
"template1"
},
}
assert
.
Equal
(
t
,
expectedCommands
,
commands
)
}
func
Test_Parser_NoFromLine
(
t
*
testing
.
T
)
{
input
:=
`
PARAMETER param1 value1
PARAMETER param2 value2
`
reader
:=
strings
.
NewReader
(
input
)
_
,
err
:=
Parse
(
reader
)
assert
.
ErrorContains
(
t
,
err
,
"no FROM line"
)
}
func
Test_Parser_MissingValue
(
t
*
testing
.
T
)
{
input
:=
`
FROM foo
PARAMETER param1
`
reader
:=
strings
.
NewReader
(
input
)
_
,
err
:=
Parse
(
reader
)
assert
.
ErrorContains
(
t
,
err
,
"missing value for [param1]"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment