Skip to content

Commit

Permalink
fix coding style of test cases: use assert.is_nil()
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed May 14, 2024
1 parent 6fa6d7f commit cc79426
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions spec/01-unit/21-dns-client/02-client_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ describe("[DNS client]", function()
local lastsuccess2 = lrucache:get("thuis.kong-gateway-testing.link")
local lastsuccess1 = lrucache:get("kong-gateway-testing.link")
assert.are.equal(client.TYPE_A, lastsuccess3)
assert.are.equal(nil, lastsuccess2)
assert.are.equal(nil, lastsuccess1)
assert.is_nil(lastsuccess2)
assert.is_nil(lastsuccess1)

-- check entries in the intermediate cache against the final output result
local key = client.TYPE_A .. ":" .. host
Expand Down
14 changes: 7 additions & 7 deletions spec/01-unit/21-dns-client/03-client_cache_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ describe("[DNS client cache]", function()

local res, _, try_list = client.resolve("myhost9", {})
assert.matches(tostring(try_list), '"myhost9.domain.com:1 - cache-miss/querying/dns client error: 101 empty record received"')
assert.equal(nil, res)
assert.is_nil(res)
end)
end)

Expand Down Expand Up @@ -512,16 +512,16 @@ describe("[DNS client cache]", function()
}

local res = client.resolve("myhost9.domain.com")

-- name has been fixed to queried name
-- The record's name has been fixed to the queried name.
assert.equal("myhost9.domain.com", res[1].name)
assert.equal(A, res[1])

local success = client.getcache():get("myhost9.domain.com")
local success = lrucache:get("myhost9.domain.com")
assert.equal(client.TYPE_A, success)

-- The CNAME records have been removed due to a mismatch with type A.
local cached = lrucache:get(client.TYPE_CNAME..":myhost9.domain.com")
assert(cached == nil, "CNAME entries are not stored as `intermediates` for A type")
assert.is_nil(cached)
end)

it("No RRs match the queried type", function()
Expand All @@ -539,7 +539,7 @@ describe("[DNS client cache]", function()

local res, err = client.resolve("myhost9.domain.com", {})
assert.equal('dns client error: 101 empty record received', err)
assert(res == nil)
assert.is_nil(res)
end)

end)
Expand Down Expand Up @@ -630,7 +630,7 @@ describe("[DNS client cache]", function()

-- It only stores SRV target entry into cache, not storing A entry.
local success = client.getcache():get("192.168.5.232.node.api_test.consul")
assert.equal(nil, success)
assert.is_nil(success)

success = client.getcache():get("demo.service.consul")
assert.equal(client.TYPE_SRV, success)
Expand Down

0 comments on commit cc79426

Please sign in to comment.