From d0f87c4381c92c3b3ec1d78bd45ae05ed8a30463 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Tue, 3 Jan 2023 20:50:43 -0800 Subject: [PATCH] added tests to ensure that implementation stays in sync with interfaces from fasten-sources lib. --- backend/pkg/database/sqlite_repository_test.go | 17 +++++++++++++++++ backend/pkg/models/source_credential_test.go | 16 ++++++++++++++++ go.mod | 3 +++ go.sum | 4 ++++ 4 files changed, 40 insertions(+) create mode 100644 backend/pkg/database/sqlite_repository_test.go create mode 100644 backend/pkg/models/source_credential_test.go diff --git a/backend/pkg/database/sqlite_repository_test.go b/backend/pkg/database/sqlite_repository_test.go new file mode 100644 index 00000000..575b0bea --- /dev/null +++ b/backend/pkg/database/sqlite_repository_test.go @@ -0,0 +1,17 @@ +package database + +import ( + sourceModels "github.com/fastenhealth/fasten-sources/clients/models" + "github.com/stretchr/testify/require" + "testing" +) + +func TestSourceCredentialInterface(t *testing.T) { + t.Parallel() + + repo := new(SqliteRepository) + + //assert + require.Implements(t, (*sourceModels.DatabaseRepository)(nil), repo, "should implement the DatabaseRepository interface from fasten-sources") + require.Implements(t, (*DatabaseRepository)(nil), repo, "should implement the DatabaseRepository interface") +} diff --git a/backend/pkg/models/source_credential_test.go b/backend/pkg/models/source_credential_test.go new file mode 100644 index 00000000..7e9792b8 --- /dev/null +++ b/backend/pkg/models/source_credential_test.go @@ -0,0 +1,16 @@ +package models + +import ( + sourceModels "github.com/fastenhealth/fasten-sources/clients/models" + "github.com/stretchr/testify/require" + "testing" +) + +func TestSourceCredentialInterface(t *testing.T) { + t.Parallel() + + sourceCred := new(SourceCredential) + + //assert + require.Implements(t, (*sourceModels.SourceCredential)(nil), sourceCred, "should implement the SourceCredential interface from fasten-sources") +} diff --git a/go.mod b/go.mod index 1ceb48cf..678b72bc 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/google/uuid v1.3.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/viper v1.12.0 + github.com/stretchr/testify v1.8.1 github.com/urfave/cli/v2 v2.11.2 golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 @@ -22,6 +23,7 @@ require ( require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fastenhealth/gofhir-models v0.0.4 // indirect github.com/fatih/color v1.13.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect @@ -48,6 +50,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/samber/lo v1.35.0 // indirect diff --git a/go.sum b/go.sum index ff042862..36f35201 100644 --- a/go.sum +++ b/go.sum @@ -344,6 +344,8 @@ github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiu github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -351,7 +353,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=