(t *testing.T, name string, script *redis.Script)
| 17 | } |
| 18 | |
| 19 | func 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 | } |
no test coverage detected
searching dependent graphs…