Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert unexpected PR #841

Merged
merged 1 commit into from
Nov 20, 2020
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
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