Skip to content

Commit

Permalink
fix namespace for test
Browse files Browse the repository at this point in the history
  • Loading branch information
cw-sakamoto committed Nov 24, 2023
1 parent c95e753 commit a712e53
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cmd/cert-manager/cert-manager_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package certmanager

import (
"fmt"
"testing"
"time"

cmapiv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
"github.com/chatwork/kibertas/util"
"github.com/chatwork/kibertas/util/notify"
"github.com/sirupsen/logrus"

Expand All @@ -15,6 +18,7 @@ import (
)

func TestNewCertManager(t *testing.T) {
t.Parallel()
logger := func() *logrus.Entry {
return logrus.NewEntry(logrus.New())
}
Expand All @@ -30,6 +34,7 @@ func TestNewCertManager(t *testing.T) {
}

func TestCheck(t *testing.T) {
t.Parallel()
logger := func() *logrus.Entry {
return logrus.NewEntry(logrus.New())
}
Expand All @@ -49,8 +54,10 @@ func TestCheck(t *testing.T) {

chatwork := &notify.Chatwork{ApiToken: "token", RoomId: "test", Logger: logger}

now := time.Now()
namespace := fmt.Sprintf("cert-manager-test-%d%02d%02d-%s", now.Year(), now.Month(), now.Day(), util.GenerateRandomString(5))
cm := &CertManager{
Checker: cmd.NewChecker("test", k8sclientset, true, logger, chatwork),
Checker: cmd.NewChecker(namespace, k8sclientset, true, logger, chatwork),
CertName: "sample",
Client: k8sclient,
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/datadog-agent/datadog-agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

func TestNewDatadogAgent(t *testing.T) {
t.Parallel()
logger := func() *logrus.Entry {
return logrus.NewEntry(logrus.New())
}
Expand All @@ -28,6 +29,7 @@ func TestNewDatadogAgent(t *testing.T) {
}

func TestCheck(t *testing.T) {
t.Parallel()
logger := func() *logrus.Entry {
return logrus.NewEntry(logrus.New())
}
Expand Down
24 changes: 24 additions & 0 deletions cmd/fluent/fluent_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package fluent

import (
"testing"

"github.com/chatwork/kibertas/util/notify"

"github.com/sirupsen/logrus"
)

func TestNewFluent(t *testing.T) {
logger := func() *logrus.Entry {
return logrus.NewEntry(logrus.New())
}
chatwork := &notify.Chatwork{}
fluent, err := NewFluent(true, logger, chatwork)
if err != nil {
t.Fatalf("NewFluent: %s", err)
}

if fluent == nil {
t.Error("Expected fluent instance, got nil")
}
}
11 changes: 10 additions & 1 deletion cmd/ingress/ingressCheck_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package ingress

import (
"fmt"
"testing"
"time"

"github.com/chatwork/kibertas/cmd"
"github.com/chatwork/kibertas/config"
"github.com/chatwork/kibertas/util"
"github.com/chatwork/kibertas/util/notify"

"github.com/sirupsen/logrus"
)

func TestNewIngress(t *testing.T) {
t.Parallel()
logger := func() *logrus.Entry {
return logrus.NewEntry(logrus.New())
}
Expand All @@ -26,6 +30,7 @@ func TestNewIngress(t *testing.T) {
}

func TestCheck(t *testing.T) {
t.Parallel()
logger := func() *logrus.Entry {
return logrus.NewEntry(logrus.New())
}
Expand All @@ -37,10 +42,14 @@ func TestCheck(t *testing.T) {

chatwork := &notify.Chatwork{ApiToken: "token", RoomId: "test", Logger: logger}

now := time.Now()

namespace := fmt.Sprintf("ingress-test-%d%02d%02d-%s", now.Year(), now.Month(), now.Day(), util.GenerateRandomString(5))

// kindとingress-nginxがある前提
// レコードは作れないのでNoDnsCheckをtrueにする
ingress := &Ingress{
Checker: cmd.NewChecker("test", k8sclient, true, logger, chatwork),
Checker: cmd.NewChecker(namespace, k8sclient, true, logger, chatwork),
NoDnsCheck: true,
IngressClassName: "nginx",
ResourceName: "sample",
Expand Down

0 comments on commit a712e53

Please sign in to comment.