valkey testy
This commit is contained in:
@@ -5,6 +5,9 @@ import (
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"ti1/config"
|
||||
"ti1/valkey"
|
||||
)
|
||||
|
||||
func InsertOrUpdateEstimatedCall(db *sql.DB, values []interface{}) (int, string, error) {
|
||||
@@ -28,8 +31,35 @@ func InsertOrUpdateEstimatedCall(db *sql.DB, values []interface{}) (int, string,
|
||||
|
||||
estimatedVehicleJourneyID := values[0]
|
||||
orderID := values[1]
|
||||
key := fmt.Sprintf("%v.%v", estimatedVehicleJourneyID, orderID)
|
||||
fmt.Printf("Estimated Vehicle Journey ID: %v, Order ID: %v\n", estimatedVehicleJourneyID, orderID)
|
||||
|
||||
// Connect to Valkey
|
||||
valkeyClient, err := config.ConnectToValkey("config/conf.json")
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to connect to Valkey: %v", err)
|
||||
}
|
||||
defer config.DisconnectFromValkey(valkeyClient)
|
||||
|
||||
// Set the MD5 hash in Valkey
|
||||
err = valkey.SetValkeyValue(valkeyClient, key, hashString)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to set value in Valkey: %v", err)
|
||||
}
|
||||
|
||||
// Get the MD5 hash from Valkey
|
||||
retrievedHash, err := valkey.GetValkeyValue(valkeyClient, key)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get value from Valkey: %v", err)
|
||||
}
|
||||
|
||||
// Check if the retrieved value matches the original MD5 hash
|
||||
if retrievedHash != hashString {
|
||||
log.Fatalf("Retrieved hash does not match the original hash. Original: %s, Retrieved: %s", hashString, retrievedHash)
|
||||
} else {
|
||||
fmt.Println("Retrieved hash matches the original hash.")
|
||||
}
|
||||
|
||||
query := `
|
||||
INSERT INTO calls (
|
||||
estimatedvehiclejourney, "order", stoppointref,
|
||||
|
||||
Reference in New Issue
Block a user