Skip to content

Commit

Permalink
improve test case
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Jan 18, 2024
1 parent e715484 commit 726c192
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tests/RedisCommandTypes.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="redis" {
defineCache();
// Setup code if needed
cacheName = "testRedis";
keyName = "test:intKey";

initialValue = 100;
redisCommand(arguments: ["SET", keyName, initialValue], cache: cacheName);

}

public function afterAll(){
Expand Down Expand Up @@ -50,39 +48,49 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="redis" {
describe("My Redis Extension Tests", function() {

it("can increment Redis key value using Float", function() {
var Float = createObject("java", "java.lang.Float");
keyName = "test:float";
redisCommand(arguments: ["SET", keyName, initialValue], cache: cacheName);
var Float = createObject("java", "java.lang.Float");
var f = Float.parseFloat("100");
redisCommand(arguments: ["INCRBY", keyName, f], cache: cacheName);
var result = redisCommand(arguments: ["GET", keyName], cache: cacheName);
expect(result).toBe(200); // Or your expected result
});

it("can increment Redis key value using Double", function() {
var Double = createObject("java", "java.lang.Double");
keyName = "test:double";
redisCommand(arguments: ["SET", keyName, initialValue], cache: cacheName);
var Double = createObject("java", "java.lang.Double");
var d = Double.parseDouble("100");
redisCommand(arguments: ["INCRBY", keyName, d], cache: cacheName);
var result = redisCommand(arguments: ["GET", keyName], cache: cacheName);
expect(result).toBe(200); // Or your expected result
});

it("can increment Redis key value using Short", function() {
var Short = createObject("java", "java.lang.Short");
keyName = "test:short";
redisCommand(arguments: ["SET", keyName, initialValue], cache: cacheName);
var Short = createObject("java", "java.lang.Short");
var s = Short.parseShort("100");
redisCommand(arguments: ["INCRBY", keyName, s], cache: cacheName);
var result = redisCommand(arguments: ["GET", keyName], cache: cacheName);
expect(result).toBe(200); // Or your expected result
});

it("can increment Redis key value using Integer", function() {
var Integer = createObject("java", "java.lang.Integer");
keyName = "test:int";
redisCommand(arguments: ["SET", keyName, initialValue], cache: cacheName);
var Integer = createObject("java", "java.lang.Integer");
var i = Integer.parseInt("100");
redisCommand(arguments: ["INCRBY", keyName, i], cache: cacheName);
var result = redisCommand(arguments: ["GET", keyName], cache: cacheName);
expect(result).toBe(200); // Or your expected result
});

it("can increment Redis key value using Long", function() {
var Long = createObject("java", "java.lang.Long");
keyName = "test:long";
redisCommand(arguments: ["SET", keyName, initialValue], cache: cacheName);
var Long = createObject("java", "java.lang.Long");
var l = Long.parseLong("100");
var res = redisCommand(arguments: ["INCRBY", keyName, l], cache: cacheName);
var result = redisCommand(arguments: ["GET", keyName], cache: cacheName);
Expand Down

0 comments on commit 726c192

Please sign in to comment.