44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package v1
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func setupNotionIntegrationRouter() *gin.Engine {
|
|
gin.SetMode(gin.TestMode)
|
|
r := gin.New()
|
|
r.RedirectTrailingSlash = false
|
|
|
|
handler := NewNotionIntegrationHandler(nil)
|
|
|
|
integrations := r.Group("/api/v1/accounts/:account_id/integrations")
|
|
RegisterNotionIntegrationRoutes(integrations, handler)
|
|
|
|
return r
|
|
}
|
|
|
|
// ========================================
|
|
// NotionIntegration — param validation tests
|
|
// ========================================
|
|
|
|
func TestNotionIntegration_Delete_BadAccountID(t *testing.T) {
|
|
r := setupNotionIntegrationRouter()
|
|
|
|
w := httptest.NewRecorder()
|
|
req, _ := http.NewRequest("DELETE", "/api/v1/accounts/abc/integrations/notion/", nil)
|
|
r.ServeHTTP(w, req)
|
|
|
|
assert.Equal(t, http.StatusBadRequest, w.Code)
|
|
|
|
var resp map[string]interface{}
|
|
json.Unmarshal(w.Body.Bytes(), &resp)
|
|
errBody := resp["error"].(map[string]interface{})
|
|
assert.Contains(t, errBody["message"], "invalid account_id")
|
|
}
|