github.com/c0olix/migrate@v3.5.4+incompatible/database/util_test.go (about) 1 package database 2 3 import ( 4 "testing" 5 ) 6 7 func TestGenerateAdvisoryLockId(t *testing.T) { 8 testcases := []struct { 9 dbname string 10 expectedID string // empty string signifies that an error is expected 11 }{ 12 {dbname: "database_name", expectedID: "1764327054"}, 13 } 14 15 for _, tc := range testcases { 16 t.Run(tc.dbname, func(t *testing.T) { 17 if id, err := GenerateAdvisoryLockId("database_name"); err == nil { 18 if id != tc.expectedID { 19 t.Error("Generated incorrect ID:", id, "!=", tc.expectedID) 20 } 21 } else { 22 if tc.expectedID != "" { 23 t.Error("Got unexpected error:", err) 24 } 25 } 26 }) 27 } 28 }