From 33e08981ad0aca87fb5dc3e92265241611c83d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matczuk?= Date: Tue, 21 Apr 2020 15:34:28 +0200 Subject: [PATCH] queryx: Add test to check that all methods are wrapped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MichaƂ Matczuk --- queryx_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/queryx_test.go b/queryx_test.go index 3291c29..ffc492e 100644 --- a/queryx_test.go +++ b/queryx_test.go @@ -5,8 +5,10 @@ package gocqlx import ( + "reflect" "testing" + "github.com/gocql/gocql" "github.com/google/go-cmp/cmp" ) @@ -149,3 +151,25 @@ func TestQueryxBindMap(t *testing.T) { } }) } + +func TestQyeryxAllWrapped(t *testing.T) { + var ( + gocqlQueryPtr = reflect.TypeOf((*gocql.Query)(nil)) + queryxPtr = reflect.TypeOf((*Queryx)(nil)) + ) + + for i := 0; i < gocqlQueryPtr.NumMethod(); i++ { + m, ok := queryxPtr.MethodByName(gocqlQueryPtr.Method(i).Name) + if !ok { + t.Fatalf("Queryx missing method %s", gocqlQueryPtr.Method(i).Name) + } + + t.Log(m.Name) + + for j := 0; j < m.Type.NumOut(); j++ { + if m.Type.Out(j) == gocqlQueryPtr { + t.Errorf("Queryx method %s not wrapped", m.Name) + } + } + } +}