Skip to content

Commit

Permalink
Add sample tests
Browse files Browse the repository at this point in the history
Signed-off-by: Aadhitya A <[email protected]>
  • Loading branch information
alphaX86 committed Mar 21, 2022
1 parent 15283a9 commit 7518e87
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 1 deletion.
16 changes: 16 additions & 0 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"testing"
)

func TestMain(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}

_, err := main()
if err != nil {
t.Errorf("main() failed with error: %s", err)
}
}
16 changes: 16 additions & 0 deletions handlers/middlewares_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package handlers

import (
"testing"
)

func TestAuthMiddleWare(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}

_, err := AuthMiddleWare(nil, nil)
if err != nil {
t.Errorf("AuthMiddleWare() failed with error: %s", err)
}
}
2 changes: 1 addition & 1 deletion helpers/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ func TestFetchKubernetesVersion(t *testing.T) {
if err != nil {
t.Error("FetchKubernetesVersion() failed")
}
}
}
16 changes: 16 additions & 0 deletions internal/channels/broker_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package channels

import (
"testing"
)

func TestNewBrokerSubscribeChannel(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}

ch := NewBrokerSubscribeChannel()
if ch == nil {
t.Error("NewBrokerSubscribeChannel() returned nil.")
}
}
17 changes: 17 additions & 0 deletions internal/sql/map_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package sql

import (
"testing"
)

var Sample map[string]interface{}

func TestScan(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
err := Map.Interface(Sample)
if err != nil {
t.Errorf("Scan() failed with error: %s", err)
}
}
18 changes: 18 additions & 0 deletions meshes/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package meshes

import (
"testing"
)

m := MeshClient("nil", "nil")

func TestClose(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}

err := m.Close()
if err != nil {
t.Errorf("Close() failed with error: %s", err)
}
}
18 changes: 18 additions & 0 deletions router/server_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package router

import (
"testing"
)

r := Router("nil", 0)

func TestClose(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}

err := r.Close()
if err != nil {
t.Errorf("Close() failed with error: %s", err)
}
}

0 comments on commit 7518e87

Please sign in to comment.