+func TestGetChartsByName(t *testing.T) {
+ svr := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ ricdms.Logger.Debug("request received by mock to get chart by name")
+ path, _ := filepath.Abs("./mocks/resp-get-charts-by-name.json")
+ file, err := os.Open(path)
+
+ if err != nil {
+ ricdms.Logger.Error("error in reading file: %v", err)
+ }
+
+ jsonData, err := io.ReadAll(file)
+ if err != nil {
+ ricdms.Logger.Error("Error in rading file: %v", err)
+ }
+ w.Write(jsonData)
+ }))
+
+ svr.Listener.Close()
+ svr.Listener, _ = net.Listen("tcp", ricdms.Config.MockServer)
+
+ svr.Start()
+ defer svr.Close()
+
+ resp := rh.GetChartsByName("TEST_NAME")
+ ricdms.Logger.Debug("resp Data: %s", resp.(*charts.GetChartOK).Payload...)
+ assert.IsType(t, &charts.GetChartOK{}, resp, "response did not match type")
+}
+
+func TestGetChartsByNameAndVersion(t *testing.T) {
+ svr := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ ricdms.Logger.Debug("request received by mock to get chart by name and version")
+ path, _ := filepath.Abs("./mocks/resp-get-charts-by-name-and-ver.json")
+ file, err := os.Open(path)
+
+ if err != nil {
+ ricdms.Logger.Error("error in reading file: %v", err)
+ }
+
+ jsonData, err := io.ReadAll(file)
+ if err != nil {
+ ricdms.Logger.Error("Error in rading file: %v", err)
+ }
+ w.Write(jsonData)
+ }))
+
+ svr.Listener.Close()
+ svr.Listener, _ = net.Listen("tcp", ricdms.Config.MockServer)
+
+ svr.Start()
+ defer svr.Close()
+
+ resp := rh.GetChartByNameAndVersion("Test", "1.0.0")
+ ricdms.Logger.Debug("resp data: %s", resp.(*charts.GetChartsFetcherOK).Payload)
+ assert.IsType(t, &charts.GetChartsFetcherOK{}, resp, "response did not match type")
+}
+
+func TestDownloadAndInstall(t *testing.T) {
+ response := rh.DownloadAndInstallChart("sample app", "1.0.0", "test")
+ if _, ok := response.(*d.PostDeployInternalServerError); !ok {
+ assert.Fail(t, "response type did not match (actual) %T", response)
+ }
+
+}
+
+func TestUninstallxApp(t *testing.T) {
+ response := rh.UninstallChart("test", "test", "test")
+ if _, ok := response.(*d.DeleteDeployInternalServerError); !ok {
+ assert.Fail(t, "response type did not match actual: %T", response)
+ }