Skip to content

Commit

Permalink
add tests for short names
Browse files Browse the repository at this point in the history
  • Loading branch information
jryannel committed Feb 14, 2024
1 parent 6cd5eb2 commit 77c6194
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/spec/module_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package spec

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestNames(t *testing.T) {
result, err := CheckFile("./testdata/names.module.yaml")
assert.NoError(t, err)
assert.Equal(t, 0, len(result.Errors))
}
50 changes: 50 additions & 0 deletions pkg/spec/schema_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package spec

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestGetDocumentType(t *testing.T) {
tests := []struct {
name string
want DocumentType
}{
{
name: "demo.idl",
want: DocumentTypeModule,
},
{
name: "demo.module.yaml",
want: DocumentTypeModule,
},
{
name: "demo.module.json",
want: DocumentTypeModule,
},
{
name: "demo.solution.yaml",
want: DocumentTypeSolution,
},
{
name: "demo.solution.json",
want: DocumentTypeSolution,
},
{
name: "rules.yaml",
want: DocumentTypeRules,
},
{
name: "rules.json",
want: DocumentTypeRules,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GetDocumentType(tt.name)
assert.NoError(t, err)
assert.Equal(t, tt.want, got)
})
}
}
21 changes: 21 additions & 0 deletions pkg/spec/testdata/names.module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: M.M
version: "1.0.0"
interfaces:
- name: A
- name: A_A
- name: a
- name: a_a
- name: a1
- name: a_1
- name: Demo
properties:
- name: a
type: bool
- name: a_a
type: bool
- name: A_a
type: bool
- name: A_A
type: bool


0 comments on commit 77c6194

Please sign in to comment.