-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprivacy_test.go
More file actions
51 lines (42 loc) · 1.26 KB
/
Copy pathprivacy_test.go
File metadata and controls
51 lines (42 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package test
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/humanjuan/golyn/app"
"github.com/humanjuan/golyn/config/loaders"
"github.com/humanjuan/golyn/globals"
v1 "github.com/humanjuan/golyn/routes/api/v1"
)
func TestFacebookDeletionEndpoint(t *testing.T) {
gin.SetMode(gin.TestMode)
// Setup mock logger
logDir := t.TempDir()
log, _ := loaders.InitLog("test_privacy", logDir, "debug", 5, 1, false)
globals.SetAppLogger(log)
defer log.Close()
router := gin.New()
v1Group := router.Group("/api/v1")
serverInfo := &app.Info{ServerVersion: "test"}
v1.RegisterPublicRoutes(v1Group, serverInfo)
methods := []string{"GET", "POST"}
for _, m := range methods {
t.Run(m+" /api/v1/privacy/facebook/deletion", func(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest(m, "/api/v1/privacy/facebook/deletion", nil)
router.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Errorf("Expected 200 OK, got %d", w.Code)
}
var resp map[string]string
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
t.Fatalf("Failed to unmarshal response: %v", err)
}
if resp["status"] != "ok" {
t.Errorf("Expected status ok, got %s", resp["status"])
}
})
}
}