
This change: 1. Reads location of airship config file from "airshipConfigPath" key in airshipui.json 2. If key does not exist, it is added to airshipui.json along with the default path of $HOME/.airship/config 3. If a user initializes or specifies a config file in a different location, that location will be written to airshipui.json and will be used in place of the default Change-Id: I1d4282be26729427d14de8b60778a347f5e4f681
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
/*
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package ctl
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"opendev.org/airship/airshipui/pkg/configs"
|
|
)
|
|
|
|
func TestHandleUnknownBaremetalSubComponent(t *testing.T) {
|
|
request := configs.WsMessage{
|
|
Type: configs.CTL,
|
|
Component: configs.Baremetal,
|
|
SubComponent: "fake_subcomponent",
|
|
}
|
|
|
|
path := "testdata/testairshipconfig"
|
|
configs.UIConfig.AirshipConfigPath = &path
|
|
|
|
user := "test"
|
|
response := HandleBaremetalRequest(&user, request)
|
|
|
|
e := "Subcomponent fake_subcomponent not found"
|
|
expected := configs.WsMessage{
|
|
Type: configs.CTL,
|
|
Component: configs.Baremetal,
|
|
SubComponent: "fake_subcomponent",
|
|
Error: &e,
|
|
}
|
|
|
|
assert.Equal(t, expected, response)
|
|
}
|