Add depot, attendant, jetfire, optimus, ota services with kustomize overlays

This commit is contained in:
Chris Rai
2026-01-31 15:35:07 -05:00
parent a0ec642ca1
commit 9a5cb2f547
404 changed files with 38817 additions and 16 deletions

View File

@@ -0,0 +1,55 @@
package handlers_test
import (
"fmt"
"net/http"
"otaupdate/handlers"
"otaupdate/services"
"testing"
"github.com/fiskerinc/cloud-services/pkg/common"
mo "github.com/fiskerinc/cloud-services/pkg/db/queries/mocks"
th "github.com/fiskerinc/cloud-services/pkg/testhelper"
)
func TestSubscriptionFeatureAdd(t *testing.T) {
mock := mo.MockSubscriptionFeatures{}
services.GetDB().SetSubFeatures(&mock)
validData := common.SubscriptionFeature{
Name: "feature_name",
Description: "description",
}
tests := []mo.DBHttpTest{
{
Name: "No data",
Request: th.MakeTestRequest(http.MethodPost, "http://example.com/subscriptionfeature", nil),
ExpectedStatus: http.StatusBadRequest,
ExpectedResponse: `{"message":"Name required. Description required","error":"Bad Request"}`,
},
{
Name: "Invalid data",
Request: th.MakeTestRequest(http.MethodPost, "http://example.com/subscriptionfeature", common.SubscriptionFeature{
Name: "feature_name",
}),
ExpectedStatus: http.StatusBadRequest,
ExpectedResponse: `{"message":"Description required","error":"Bad Request"}`,
},
{
Name: "Valid data",
Request: th.MakeTestRequest(http.MethodPost, "http://example.com/subscriptionfeature", validData),
ExpectedStatus: http.StatusOK,
ExpectedResponse: `{"id":"ecfb89e0-ca03-4aa9-a43a-a9d703256edb","name":"feature_name","description":"description"}`,
},
{
Name: "DB error",
Request: th.MakeTestRequest(http.MethodPost, "http://example.com/subscriptionfeature", validData),
ExpectedStatus: http.StatusServiceUnavailable,
ExpectedResponse: `{"message":"something went wrong","error":"Service Unavailable"}`,
DBTestCase: mo.DBTestCase{
MockError: fmt.Errorf("something went wrong"),
},
},
}
mo.RunDBTests(t, tests, handlers.HandleSubscriptionFeatureAdd, &mock)
}