repogen/internal/spec/models_test.go

46 lines
895 B
Go
Raw Normal View History

2021-02-14 04:48:09 +00:00
package spec_test
import (
"testing"
2023-05-24 11:01:50 +00:00
"git.kmsign.com/royalcat/repogen/internal/spec"
2021-02-14 04:48:09 +00:00
)
type OperationTestCase struct {
Operation spec.Operation
ExpectedName string
}
func TestOperationName(t *testing.T) {
testTable := []OperationTestCase{
{
Operation: spec.InsertOperation{},
ExpectedName: "Insert",
},
{
Operation: spec.FindOperation{},
ExpectedName: "Find",
},
{
Operation: spec.UpdateOperation{},
ExpectedName: "Update",
},
{
Operation: spec.DeleteOperation{},
ExpectedName: "Delete",
},
{
Operation: spec.CountOperation{},
ExpectedName: "Count",
},
}
for _, testCase := range testTable {
t.Run(testCase.ExpectedName, func(t *testing.T) {
if testCase.Operation.Name() != testCase.ExpectedName {
2021-03-31 11:44:31 +00:00
t.Errorf("Expected = %+v\nReceived = %+v", testCase.ExpectedName, testCase.Operation.Name())
2021-02-14 04:48:09 +00:00
}
})
}
}