//go:build end2end // +build end2end package end2end import ( "context" "fmt" "net/http" "net/http/httptest" "testing" "git.gocasts.ir/ebhomengo/niki/delivery/http_server/end2end/setup" adminserviceparam "git.gocasts.ir/ebhomengo/niki/param/admin/admin" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" ) func TestAdmin_KindBox_Get(t *testing.T) { teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig()) t.Cleanup(teardown) // Get token lRes, err := services.AdminSvc.LoginWithPhoneNumber(context.Background(), adminserviceparam.LoginWithPhoneNumberRequest{ PhoneNumber: "09384664402", Password: "Abc123456", }) if err != nil { t.Fatalf("could not login: %s", err) } // Create a request req := httptest.NewRequest(http.MethodGet, "/admin/kindboxes/1", nil) req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken)) rec := httptest.NewRecorder() // Serve the request testServer.Serve(rec, req) // Assertions assert.Equal(t, http.StatusOK, rec.Code) }