MCPcopy Index your code
hub / github.com/go-redsync/redsync / testScriptHash

Function testScriptHash

scripts_test.go:19–51  ·  view source on GitHub ↗
(t *testing.T, name string, script *redis.Script)

Source from the content-addressed store, hash-verified

17}
18
19func testScriptHash(t *testing.T, name string, script *redis.Script) {
20 t.Run(name, func(t *testing.T) {
21 server, err := tempredis.Start(tempredis.Config{})
22 if err != nil {
23 t.Fatal(err)
24 }
25 defer server.Term()
26
27 client := goredislib_v9.NewClient(&goredislib_v9.Options{
28 Network: "unix",
29 Addr: server.Socket(),
30 })
31
32 pool := goredis.NewPool(client)
33 conn, err := pool.Get(context.Background())
34 if err != nil {
35 t.Fatal(err)
36 }
37
38 dupscript := redis.NewScript(script.KeyCount, script.Src, "")
39 err = conn.ScriptLoad(dupscript)
40 if err != nil {
41 t.Fatal(err)
42 }
43
44 if dupscript.Hash == "" {
45 t.Fatal("script hash is empty")
46 }
47 if dupscript.Hash != script.Hash {
48 t.Fatalf("script hash mismatch; want %s, got %s", script.Hash, dupscript.Hash)
49 }
50 })
51}

Callers 1

TestScripts_HashFunction · 0.85

Calls 3

GetMethod · 0.95
NewScriptFunction · 0.92
ScriptLoadMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…