Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] "oscalkit" utility #60

Closed
wants to merge 15 commits into from
Prev Previous commit
validator mock
  • Loading branch information
Andrew Weiss committed Oct 12, 2017

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
commit 469e0c47970014994228bc89a8af9a20916a7f9c
35 changes: 35 additions & 0 deletions oscalkit/validator/validator_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
package validator

import (
"errors"
"reflect"
"testing"
)

type mockValidator struct{}

func (m mockValidator) Validate(files ...string) error {
if len(files) <= 0 {
return errors.New("No files to validate")
}

return nil
}

func TestNew(t *testing.T) {
type args struct {
schemaFile string
@@ -27,6 +38,30 @@ func TestNew(t *testing.T) {
}
}

func TestValidator(t *testing.T) {
type args struct {
files []string
}
tests := []struct {
name string
args args
wantErr bool
}{
{"validation succeeded", args{[]string{""}}, false},
{"validation failed", args{}, true},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
mock := mockValidator{}
if err := mock.Validate(tt.args.files...); (err != nil) != tt.wantErr {
t.Errorf("Validation failed %v", err)
}
})
}

}

func TestJSONValidate(t *testing.T) {
type fields struct {
SchemaFile string