Skip to content

Commit

Permalink
test: add some more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Rose <matthew.rose@maxkelsen.com>
  • Loading branch information
matty-rose committed Oct 25, 2021
1 parent f35ade7 commit 299c4ae
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/generator/generator_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2021 Matt Rose <matthewrose153@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package generator_test

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/matty-rose/gha-docs/pkg/generator"
)

func TestInvalidFormat(t *testing.T) {
t.Parallel()

g, err := generator.New("invalid")

assert.Nil(t, g)
assert.Error(t, err)
}
18 changes: 18 additions & 0 deletions pkg/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,21 @@ func TestParseUses(t *testing.T) {

assert.Len(t, action.Uses, 3)
}

func TestNoFile(t *testing.T) {
t.Parallel()

action, err := parser.Parse("./testdata/doesnt_exist.yaml")

assert.Nil(t, action)
assert.Error(t, err)
}

func TestInvalidYAML(t *testing.T) {
t.Parallel()

action, err := parser.Parse("./testdata/invalid.yaml")

assert.Nil(t, action)
assert.Error(t, err)
}
1 change: 1 addition & 0 deletions pkg/parser/testdata/invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
some invalid text}

0 comments on commit 299c4ae

Please sign in to comment.