Skip to content

Commit

Permalink
revert unreviewed pr (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiningRush authored Nov 20, 2020
1 parent 355c74e commit f01874c
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 106 deletions.
2 changes: 1 addition & 1 deletion api/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type Config struct {
Authentication Authentication
}

func InitConf() {
func init() {
//go test
if workDir := os.Getenv("APISIX_API_WORKDIR"); workDir != "" {
WorkDir = workDir
Expand Down
51 changes: 0 additions & 51 deletions api/internal/core/store/store_mock.go

This file was deleted.

51 changes: 0 additions & 51 deletions api/internal/handler/consumer/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ package consumer

import (
"encoding/json"
"fmt"
"github.com/shiningrush/droplet/data"
"github.com/stretchr/testify/mock"
"net/http"
"testing"
"time"

Expand All @@ -34,53 +30,6 @@ import (
"github.com/apisix/manager-api/internal/core/store"
)

func TestHandler_Get(t *testing.T) {
tests := []struct {
caseDesc string
giveInput *GetInput
giveRet interface{}
giveErr error
wantErr error
wantGetKey string
wantRet interface{}
}{
{
caseDesc: "normal",
giveInput: &GetInput{Username: "test"},
wantGetKey: "test",
giveRet: "hello",
wantRet: "hello",
},
{
caseDesc: "failed",
giveInput: &GetInput{Username: "failed key"},
wantGetKey: "failed key",
giveErr: fmt.Errorf("get failed"),
wantErr: fmt.Errorf("get failed"),
wantRet: &data.SpecCodeResponse{
StatusCode: http.StatusInternalServerError,
},
},
}

for _, tc := range tests {
getCalled := true
mStore := &store.MockInterface{}
mStore.On("Get", mock.Anything).Run(func(args mock.Arguments) {
getCalled = true
assert.Equal(t, tc.wantGetKey, args.Get(0), tc.caseDesc)
}).Return(tc.giveRet, tc.giveErr)

h := Handler{consumerStore: mStore}
ctx := droplet.NewContext()
ctx.SetInput(tc.giveInput)
ret, err := h.Get(ctx)
assert.True(t, getCalled, tc.caseDesc)
assert.Equal(t, tc.wantRet, ret, tc.caseDesc)
assert.Equal(t, tc.wantErr, err, tc.caseDesc)
}
}

func TestConsumer(t *testing.T) {
// init
err := storage.InitETCDClient([]string{"127.0.0.1:2379"})
Expand Down
2 changes: 1 addition & 1 deletion api/log/zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

var logger *zap.SugaredLogger

func InitLog() {
func init() {
writeSyncer := fileWriter()
encoder := getEncoder()
logLevel := getLogLevel()
Expand Down
3 changes: 1 addition & 2 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import (
)

func main() {
conf.InitConf()
log.InitLog()

if err := storage.InitETCDClient(conf.ETCDEndpoints); err != nil {
log.Error("init etcd client fail: %w", err)
panic(err)
Expand Down

0 comments on commit f01874c

Please sign in to comment.