* H-300: wire Captain Skills into Web runtime * H-300: enforce effective model and conservative skill budget * H-300: fix CI gosec step * ci: extend golangci-lint timeout * fix lint findings across backend * fix(push): resolve delivery protocol blockers * test(repository): close SQLite test databases * test(repository): reuse SQLite schema per package * H-307: restore backend Go cache in CI * H-307: prefetch modules before cold lint * H-307: resolve govulncheck security gate * H-307: build lint with patched Go toolchain * H-307: clear remaining security scan findings --------- Co-authored-by: Rogee <rogee@ipao.vip>
156 lines
5.0 KiB
Go
156 lines
5.0 KiB
Go
package v1
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"net/http"
|
|
"net/http/httptest"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func safeCall_Cov25(fn func()) { defer func() { _ = recover() }(); fn() }
|
|
|
|
func newInstagramHandler_Cov25() *InstagramChannelHandler {
|
|
return &InstagramChannelHandler{}
|
|
}
|
|
|
|
func TestInstagramHandler_OAuthCallbackGET_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInstagramHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodGet, "/", nil)
|
|
safeCall_Cov25(func() { h.OAuthCallbackGET(c) })
|
|
}
|
|
|
|
func TestInstagramHandler_DeleteInstagramChannel_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInstagramHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodDelete, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}, {Key: "inbox_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.DeleteInstagramChannel(c) })
|
|
}
|
|
|
|
func TestInstagramHandler_Reauthorize_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInstagramHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodPost, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}, {Key: "inbox_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.Reauthorize(c) })
|
|
}
|
|
|
|
func TestInstagramHandler_UpdateInstagramChannel_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInstagramHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodPatch, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}, {Key: "inbox_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.UpdateInstagramChannel(c) })
|
|
}
|
|
|
|
func TestInstagramHandler_CreateInstagramChannel_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInstagramHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodPost, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.CreateInstagramChannel(c) })
|
|
}
|
|
|
|
// Inbox handler tests
|
|
func newInboxHandler_Cov25() *InboxHandler {
|
|
return &InboxHandler{}
|
|
}
|
|
|
|
func TestInboxHandler_List_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInboxHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodGet, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.List(c) })
|
|
}
|
|
|
|
func TestInboxHandler_Create_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInboxHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodPost, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.Create(c) })
|
|
}
|
|
|
|
func TestInboxHandler_Update_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInboxHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodPatch, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}, {Key: "id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.Update(c) })
|
|
}
|
|
|
|
func TestInboxHandler_Delete_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newInboxHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodDelete, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}, {Key: "id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.Delete(c) })
|
|
}
|
|
|
|
// Contact handler tests
|
|
func newContactHandler_Cov25() *ContactHandler {
|
|
return &ContactHandler{}
|
|
}
|
|
|
|
func TestContactHandler_List_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newContactHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodGet, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.List(c) })
|
|
}
|
|
|
|
func TestContactHandler_Create_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newContactHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodPost, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.Create(c) })
|
|
}
|
|
|
|
func TestContactHandler_Update_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newContactHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodPut, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}, {Key: "id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.Update(c) })
|
|
}
|
|
|
|
func TestContactHandler_Delete_Cov25(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
h := newContactHandler_Cov25()
|
|
w := httptest.NewRecorder()
|
|
c, _ := gin.CreateTestContext(w)
|
|
c.Request = httptest.NewRequest(http.MethodDelete, "/", nil)
|
|
c.Params = gin.Params{{Key: "account_id", Value: "1"}, {Key: "id", Value: "1"}}
|
|
safeCall_Cov25(func() { h.Delete(c) })
|
|
}
|