Files

34 lines
1.1 KiB
Go

package upstreamimpl
import (
"context"
"testing"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model/entity"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/service"
)
func TestApikaTemplateRegistration(t *testing.T) {
template, ok := service.UpstreamAPI().GetTemp(sharedOneLinkApikaTemplateKey)
if !ok || template == nil {
t.Fatal("apika template not registered")
}
config := &model.SimChannelConfigItemCache{
Template: &entity.TSimChannelTemplate{
TempKey: sharedOneLinkApikaTemplateKey,
TempConfig: `{"token":{"provider":"apika","baseUrl":"https://example.com","path":"/iot-api/iot-card-info/getRefreshToken"},"api":{"baseUrl":"https://api.iot.10086.cn/v5/","timeout":"1s"}}`,
},
Channel: &entity.TSimChannels{
ChanKey: "apika-test",
ChanConfig: `{"appId":"appid"}`,
AppKey: "app-key",
AppSecret: "app-secret",
},
}
if instance := template.NewTemp(context.Background(), config); instance == nil {
t.Fatal("apika template failed to instantiate")
}
}