From e8e4cfc1e0f7a7dde5cfa6e8fe1821a6aa354685 Mon Sep 17 00:00:00 2001 From: Josh Kaplinsky <37640086+joshkaplinsky@users.noreply.github.com> Date: Thu, 10 Apr 2025 09:28:51 -0400 Subject: [PATCH] chore: add unit tests for code cov --- generator/template/model_template_test.go | 32 +++++++++++++++++-- .../template/sql_builder_template_test.go | 32 +++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/generator/template/model_template_test.go b/generator/template/model_template_test.go index a7bbe28..0fce487 100644 --- a/generator/template/model_template_test.go +++ b/generator/template/model_template_test.go @@ -1,9 +1,11 @@ package template import ( - "github.com/go-jet/jet/v2/generator/metadata" - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" + + "github.com/go-jet/jet/v2/generator/metadata" ) func Test_TableModelField(t *testing.T) { @@ -43,3 +45,29 @@ func Test_TableModelField(t *testing.T) { 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) + }) + } +} diff --git a/generator/template/sql_builder_template_test.go b/generator/template/sql_builder_template_test.go index b980a60..9d6dcdb 100644 --- a/generator/template/sql_builder_template_test.go +++ b/generator/template/sql_builder_template_test.go @@ -1,9 +1,11 @@ package template import ( - "github.com/go-jet/jet/v2/generator/metadata" - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" + + "github.com/go-jet/jet/v2/generator/metadata" ) 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) + }) + } +}