Skip to content

Commit

Permalink
parser: test 'package' directive and bad keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
ema committed Nov 17, 2022
1 parent 8bc357a commit 163cef3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ func TestParseModelineErr(t *testing.T) {
assertError(t, err)
}

func TestParseModelineOK(t *testing.T) {
func TestParseModelineBadKeyword(t *testing.T) {
var pf PetsFile
err := ParseModeline("# pets: something=funny", &pf)
assertError(t, err)
}

func TestParseModelineOKDestfile(t *testing.T) {
var pf PetsFile
err := ParseModeline("# pets: destfile=/etc/ssh/sshd_config, owner=root, group=root, mode=0644", &pf)
assertNoError(t, err)
Expand All @@ -44,3 +50,12 @@ func TestParseModelineOK(t *testing.T) {
assertEquals(t, pf.Group.Gid, "0")
assertEquals(t, pf.Mode, "0644")
}

func TestParseModelineOKPackage(t *testing.T) {
var pf PetsFile
err := ParseModeline("# pets: package=vim", &pf)
assertNoError(t, err)

assertEquals(t, pf.Dest, "")
assertEquals(t, string(pf.Pkgs[0]), "vim")
}

0 comments on commit 163cef3

Please sign in to comment.