MCPcopy Create free account
hub / github.com/ebosas/microservices / testUpdateRedis

Function testUpdateRedis

cmd/server/api_test.go:52–68  ·  view source on GitHub ↗

testUpdateRedis inserts a marshalled message into mock redis

(t *testing.T, c *redis.Client, message string)

Source from the content-addressed store, hash-verified

50
51// testUpdateRedis inserts a marshalled message into mock redis
52func testUpdateRedis(t *testing.T, c *redis.Client, message string) {
53 time := time.Now().UnixMilli()
54 inputMsg := models.Message{Text: message, Source: "back", Time: time}
55 messageJson, err := json.Marshal(inputMsg)
56 if err != nil {
57 t.Fatalf("marshal message: %s", err)
58 }
59
60 if _, err := c.Pipelined(ctx, func(pipe redis.Pipeliner) error {
61 pipe.LPush(ctx, "messages", messageJson)
62 pipe.LTrim(ctx, "messages", 0, 9)
63 pipe.Incr(ctx, "total")
64 return nil
65 }); err != nil {
66 t.Fatalf("update redis: %s", err)
67 }
68}

Callers 1

TestAPICacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected