+func TestInfoWithSomeStatisticsOfStandalonePrimaryRedis(t *testing.T) {
+ _, r, db := setupHaEnv(true)
+ redisInfo := "# Replication\r\n" +
+ "role:master\r\n" +
+ "connected_slaves:0\r\n" +
+ "min_slaves_good_slaves:0\r\n" +
+ "# Server\r\n" +
+ "uptime_in_days:23\r\n" +
+ "# Clients\r\n" +
+ "connected_clients:2\r\n" +
+ "# Memory\r\n" +
+ "used_memory:2093808\r\n" +
+ "used_memory_human:2.00M\r\n" +
+ "mem_fragmentation_ratio:6.44\r\n" +
+ "# Stats\r\n" +
+ "total_connections_received:278\r\n" +
+ "# CPU\r\n" +
+ "used_cpu_sys:1775.254919\r\n" +
+ "# Commandstats\r\n" +
+ "# cmdstat_role:calls=1,usec=3,usec_per_call=3.00\r\n" +
+ "# Keyspace\r\n" +
+ "db0:keys=4,expires=0,avg_ttl=0"
+ expInfo := &sdlgoredis.DbInfo{
+ Fields: sdlgoredis.DbInfoFields{
+ PrimaryRole: true,
+ ConnectedReplicaCnt: 0,
+ Server: sdlgoredis.ServerInfoFields{
+ UptimeInDays: 23,
+ },
+ Clients: sdlgoredis.ClientsInfoFields{
+ ConnectedClients: 2,
+ },
+ Memory: sdlgoredis.MeroryInfoFields{
+ UsedMemory: 2093808,
+ UsedMemoryHuman: "2.00M",
+ MemFragmentationRatio: 6.44,
+ },
+ Stats: sdlgoredis.StatsInfoFields{
+ TotalConnectionsReceived: 278,
+ },
+ Cpu: sdlgoredis.CpuInfoFields{
+ UsedCpuSys: 1775.254919,
+ },
+ Commandstats: sdlgoredis.CommandstatsInfoFields{
+ CmdstatRole: sdlgoredis.CommandstatsValues{
+ Calls: 1,
+ Usec: 3,
+ UsecPerCall: 3.00,
+ },
+ },
+ Keyspace: sdlgoredis.KeyspaceInfoFields{
+ Db: sdlgoredis.KeyspaceValues{
+ Keys: 4,
+ },
+ },
+ },
+ }
+
+ r.On("Info", []string{"all"}).Return(redis.NewStringResult(redisInfo, nil))
+ info, err := db.Info()
+ assert.Nil(t, err)
+ assert.Equal(t, expInfo, info)
+ r.AssertExpectations(t)
+}
+