Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions gateway/controller/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "controller",
srcs = ["ping.go", "land.go"],
srcs = [
"land.go",
"ping.go",
],
importpath = "github.com/uber/submitqueue/gateway/controller",
visibility = ["//visibility:public"],
deps = [
Expand All @@ -14,7 +17,10 @@ go_library(

go_test(
name = "controller_test",
srcs = ["ping_test.go", "land_test.go"],
srcs = [
"land_test.go",
"ping_test.go",
],
embed = [":controller"],
deps = [
"//gateway/protopb",
Expand Down
7 changes: 0 additions & 7 deletions gateway/controller/land.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ type LandController struct {

// NewLandController creates a new instance of the gateway land controller
func NewLandController(logger *zap.Logger, scope tally.Scope) *LandController {
if logger == nil {
logger = zap.NewNop()
}
if scope == nil {
scope = tally.NoopScope
}

return &LandController{
logger: logger,
metricsScope: scope,
Expand Down
6 changes: 4 additions & 2 deletions gateway/controller/land_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/uber-go/tally/v4"
pb "github.com/uber/submitqueue/gateway/protopb"
"go.uber.org/zap"
)

func TestNewLandController(t *testing.T) {
controller := NewLandController(nil, nil)
controller := NewLandController(zap.NewNop(), tally.NoopScope)
require.NotNil(t, controller)
}

func TestLand_ReturnsSqid(t *testing.T) {
controller := NewLandController(nil, nil)
controller := NewLandController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.LandRequest{
Expand Down
7 changes: 0 additions & 7 deletions gateway/controller/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ type PingController struct {

// NewPingController creates a new instance of the gateway ping controller
func NewPingController(logger *zap.Logger, scope tally.Scope) *PingController {
if logger == nil {
logger = zap.NewNop()
}
if scope == nil {
scope = tally.NoopScope
}

return &PingController{
logger: logger,
metricsScope: scope,
Expand Down
14 changes: 8 additions & 6 deletions gateway/controller/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber-go/tally/v4"
pb "github.com/uber/submitqueue/gateway/protopb"
"go.uber.org/zap"
)

func TestNewPingController(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
require.NotNil(t, controller)
}

func TestPing_DefaultMessage(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand All @@ -27,7 +29,7 @@ func TestPing_DefaultMessage(t *testing.T) {
}

func TestPing_CustomMessage(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

testCases := []struct {
Expand All @@ -52,7 +54,7 @@ func TestPing_CustomMessage(t *testing.T) {
}

func TestPing_ServiceName(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand All @@ -63,7 +65,7 @@ func TestPing_ServiceName(t *testing.T) {
}

func TestPing_Timestamp(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

before := time.Now().Unix()
Expand All @@ -77,7 +79,7 @@ func TestPing_Timestamp(t *testing.T) {
}

func TestPing_Hostname(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand Down
7 changes: 0 additions & 7 deletions orchestrator/controller/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ type PingController struct {

// NewPingController creates a new instance of the orchestrator ping controller
func NewPingController(logger *zap.Logger, scope tally.Scope) *PingController {
if logger == nil {
logger = zap.NewNop()
}
if scope == nil {
scope = tally.NoopScope
}

return &PingController{
logger: logger,
metricsScope: scope,
Expand Down
14 changes: 8 additions & 6 deletions orchestrator/controller/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber-go/tally/v4"
pb "github.com/uber/submitqueue/orchestrator/protopb"
"go.uber.org/zap"
)

func TestNewPingController(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
require.NotNil(t, controller)
}

func TestPing_DefaultMessage(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand All @@ -27,7 +29,7 @@ func TestPing_DefaultMessage(t *testing.T) {
}

func TestPing_CustomMessage(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

testCases := []struct {
Expand All @@ -52,7 +54,7 @@ func TestPing_CustomMessage(t *testing.T) {
}

func TestPing_ServiceName(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand All @@ -63,7 +65,7 @@ func TestPing_ServiceName(t *testing.T) {
}

func TestPing_Timestamp(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

before := time.Now().Unix()
Expand All @@ -77,7 +79,7 @@ func TestPing_Timestamp(t *testing.T) {
}

func TestPing_Hostname(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand Down
7 changes: 0 additions & 7 deletions speculator/controller/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ type PingController struct {

// NewPingController creates a new instance of the speculator ping controller
func NewPingController(logger *zap.Logger, scope tally.Scope) *PingController {
if logger == nil {
logger = zap.NewNop()
}
if scope == nil {
scope = tally.NoopScope
}

return &PingController{
logger: logger,
metricsScope: scope,
Expand Down
14 changes: 8 additions & 6 deletions speculator/controller/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber-go/tally/v4"
pb "github.com/uber/submitqueue/speculator/protopb"
"go.uber.org/zap"
)

func TestNewPingController(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
require.NotNil(t, controller)
}

func TestPing_DefaultMessage(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand All @@ -27,7 +29,7 @@ func TestPing_DefaultMessage(t *testing.T) {
}

func TestPing_CustomMessage(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

testCases := []struct {
Expand All @@ -52,7 +54,7 @@ func TestPing_CustomMessage(t *testing.T) {
}

func TestPing_ServiceName(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand All @@ -63,7 +65,7 @@ func TestPing_ServiceName(t *testing.T) {
}

func TestPing_Timestamp(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

before := time.Now().Unix()
Expand All @@ -77,7 +79,7 @@ func TestPing_Timestamp(t *testing.T) {
}

func TestPing_Hostname(t *testing.T) {
controller := NewPingController(nil, nil)
controller := NewPingController(zap.NewNop(), tally.NoopScope)
ctx := context.Background()

req := &pb.PingRequest{}
Expand Down