2 * Copyright 2020 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 func TestGetConfSuccess(t *testing.T) {
28 _, err := service.GetConf("../../conf/app_instance_info.yaml")
30 t.Error("Read conf file failed")
34 func TestGetConfFail(t *testing.T) {
35 _, err := service.GetConf("../conf/app_instance_info.yaml")
37 t.Error("Read conf file failed")
41 func TestRegisterToMepSuccess(t *testing.T) {
42 httpResponse := "response body"
43 var httpResponseBytes, err1 = json.Marshal(httpResponse)
45 t.Error("Marshal http Response Error")
48 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
49 w.WriteHeader(http.StatusCreated)
50 _, err2 := w.Write(httpResponseBytes)
53 t.Error("Write Response Error")
55 if r.Method != "POST" {
56 t.Error("UnExcepted Method")
63 _, err := service.RegisterToMep("param", api)
69 func TestRegisterToMepFail1(t *testing.T) {
70 httpResponse := "response body"
71 var httpResponseBytes, err1 = json.Marshal(httpResponse)
73 t.Error("Marshal http Response Error")
76 ts2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
77 w.WriteHeader(http.StatusBadRequest)
78 _, err2 := w.Write(httpResponseBytes)
81 t.Error("Write Response Error")
83 if r.Method != "POST" {
84 t.Error("UnExcepted Method")
91 _, err := service.RegisterToMep("param", api)