@@ 0,0 1,2 @@
+github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
+github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
@@ 0,0 1,71 @@
+package sqlh
+
+import (
+ "testing"
+)
+
+type Test2 struct {
+ A string
+ B int
+ C string
+}
+
+type Test struct {
+ Name string
+ unexportedInt int
+ Count int
+ Blah Test2
+ Test2 string `db:"TEST3"`
+ DB int
+ ID int
+ APITestFunc string
+}
+
+func makeTestVar() Test {
+ return Test{
+ Name: "Test",
+ unexportedInt: 12,
+ Count: 5,
+ Test2: "Hello",
+ APITestFunc: "1234",
+ ID: 14,
+ Blah: Test2{
+ A: "123",
+ B: 4,
+ C: "567",
+ },
+ }
+}
+
+func TestBuildInsert(t *testing.T) {
+ FormatChar = "$"
+ FormatCounter = true
+ SkipFields = "ID, C,Name"
+
+ t.Log("Testing Insert")
+ columns, params, _ := BuildInsert(makeTestVar())
+
+ if columns != "count, a, b, TEST3, db, api_test_func" {
+ t.Log("Columns are wrong")
+ t.Fail()
+ }
+
+ if params != "$1, $2, $3, $4, $5, $6" {
+ t.Log("Parameters are wrong")
+ t.Fail()
+ }
+}
+
+func TestBuildUpdate(t *testing.T) {
+ FormatChar = "$"
+ FormatCounter = true
+ SkipFields = "ID, C,Name"
+
+ t.Log("Testing Update")
+ columns, _ := BuildUpdate(makeTestVar())
+
+ if columns != "count=$1, a=$2, b=$3, TEST3=$4, db=$5, api_test_func=$6" {
+ t.Log("Columns are wrong")
+ t.Fail()
+ }
+}