2 * Copyright (c) 2018 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial Project
18 func TestSetConsulAddress(t *testing.T) {
24 want: `http://127.0.0.1:8500`,
28 want: `http://localhost:8500`,
31 path: `controller.go`,
32 want: `http://localhost:8500`,
36 for _, cas := range cases {
37 res := getConsulAddress(cas.path)
39 t.Errorf("getConsulAddress() => want %s, got %s", cas.want, res)
44 func TestLoadCfgInfo(t *testing.T) {
54 status: `path is empty`,
57 path: `controller.go`,
58 status: `yaml format error`,
62 for _, cas := range cases {
63 _, err := loadCfgInfo(cas.path)
64 if (cas.status == "success" && err != nil) || (cas.status != "success" && err == nil) {
65 t.Errorf("loadCfgInfo() => want %s, got %v", cas.status, err)