
This patch does the following: 1. Simplify the client websocket message transformation 2. Move the cmd/airshipui to cmd 3. move internal to pkg 4. Clean up the copyright checker 5. clean up the linting in the makefile Change-Id: I1381d025e8058cbfba44b58ec3c2ec5c2aa36de5
67 lines
1.8 KiB
Go
67 lines
1.8 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"
|
|
"opendev.org/airship/airshipui/util/utiltest"
|
|
)
|
|
|
|
func TestHandleDefaultDocumentRequest(t *testing.T) {
|
|
utiltest.InitConfig(t)
|
|
|
|
request := configs.WsMessage{
|
|
Type: configs.AirshipCTL,
|
|
Component: configs.Document,
|
|
SubComponent: configs.GetDefaults,
|
|
}
|
|
|
|
response := HandleDocumentRequest(request)
|
|
|
|
expected := configs.WsMessage{
|
|
Type: configs.AirshipCTL,
|
|
Component: configs.Document,
|
|
SubComponent: configs.GetDefaults,
|
|
Data: getGraphData(),
|
|
}
|
|
|
|
assert.Equal(t, expected.Type, response.Type)
|
|
assert.Equal(t, expected.Component, response.Component)
|
|
assert.Equal(t, expected.SubComponent, response.SubComponent)
|
|
assert.Equal(t, expected.Data, response.Data)
|
|
}
|
|
|
|
func TestHandleUnknownDocumentSubComponent(t *testing.T) {
|
|
request := configs.WsMessage{
|
|
Type: configs.AirshipCTL,
|
|
Component: configs.Document,
|
|
SubComponent: "fake_subcomponent",
|
|
}
|
|
|
|
response := HandleDocumentRequest(request)
|
|
|
|
expected := configs.WsMessage{
|
|
Type: configs.AirshipCTL,
|
|
Component: configs.Document,
|
|
SubComponent: "fake_subcomponent",
|
|
Error: "Subcomponent fake_subcomponent not found",
|
|
}
|
|
|
|
assert.Equal(t, expected, response)
|
|
}
|