You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/02/05 08:53:49 UTC
[GitHub] [apisix-dashboard] idbeta commented on a change in pull request #1315: feat: refactor route unit test
idbeta commented on a change in pull request #1315:
URL: https://github.com/apache/apisix-dashboard/pull/1315#discussion_r570811168
##########
File path: api/internal/handler/route/route_test.go
##########
@@ -14,1743 +14,1421 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package route
import (
"encoding/json"
+ "errors"
+ "fmt"
"net/http"
"testing"
- "time"
"github.com/shiningrush/droplet"
"github.com/shiningrush/droplet/data"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/mock"
- "github.com/apisix/manager-api/internal/conf"
"github.com/apisix/manager-api/internal/core/entity"
- "github.com/apisix/manager-api/internal/core/storage"
"github.com/apisix/manager-api/internal/core/store"
+ "github.com/apisix/manager-api/internal/handler"
+ "github.com/apisix/manager-api/internal/utils/consts"
)
-func TestRoute(t *testing.T) {
- // init
- err := storage.InitETCDClient(conf.ETCDConfig)
- assert.Nil(t, err)
- err = store.InitStores()
- assert.Nil(t, err)
+type testCase struct {
+ caseDesc string
+ giveInput interface{}
+ mockInput interface{}
+ mockRet interface{}
+ mockErr interface{}
+ wantRet interface{}
+ wantErr interface{}
+ called bool
+ serviceInput string
+ scriptRet interface{}
+ scriptErr error
+ serviceRet interface{}
+ serviceErr error
+ upstreamRet interface{}
+ upstreamErr error
+}
- handler := &Handler{
- routeStore: store.GetStore(store.HubKeyRoute),
- svcStore: store.GetStore(store.HubKeyService),
- upstreamStore: store.GetStore(store.HubKeyUpstream),
- scriptStore: store.GetStore(store.HubKeyScript),
+var DagScript = `
Review comment:
why? Isn't cleaner after code and data separation ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org