chore: add unit tests for code cov
This commit is contained in:
parent
436a72ae5c
commit
e8e4cfc1e0
2 changed files with 60 additions and 4 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
package template
|
package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-jet/jet/v2/generator/metadata"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/go-jet/jet/v2/generator/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_TableModelField(t *testing.T) {
|
func Test_TableModelField(t *testing.T) {
|
||||||
|
|
@ -43,3 +45,29 @@ func Test_TableModelField(t *testing.T) {
|
||||||
Tags: nil,
|
Tags: nil,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Model_ShouldSkip(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
initial Model
|
||||||
|
skip bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "True",
|
||||||
|
initial: Model{Skip: false},
|
||||||
|
skip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "False",
|
||||||
|
initial: Model{Skip: true},
|
||||||
|
skip: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
updatedModel := tt.initial.ShouldSkip(tt.skip)
|
||||||
|
require.Equal(t, tt.skip, updatedModel.Skip)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
package template
|
package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-jet/jet/v2/generator/metadata"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/go-jet/jet/v2/generator/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestToGoEnumValueIdentifier(t *testing.T) {
|
func TestToGoEnumValueIdentifier(t *testing.T) {
|
||||||
|
|
@ -35,3 +37,29 @@ func TestColumnRenameReserved(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_SQLBuilder_ShouldSkip(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
initial SQLBuilder
|
||||||
|
skip bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "True",
|
||||||
|
initial: SQLBuilder{Skip: false},
|
||||||
|
skip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "False",
|
||||||
|
initial: SQLBuilder{Skip: true},
|
||||||
|
skip: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
updatedBuilder := tt.initial.ShouldSkip(tt.skip)
|
||||||
|
require.Equal(t, tt.skip, updatedBuilder.Skip)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue