@@ -6,6 +6,9 @@ package openid
66import (
77 "testing"
88 "time"
9+
10+ "github.com/stretchr/testify/assert"
11+ "github.com/stretchr/testify/require"
912)
1013
1114type testDiscoveredInfo struct {}
@@ -29,21 +32,17 @@ func TestTimedDiscoveryCache(t *testing.T) {
2932 dc .Put ("foo" , & testDiscoveredInfo {}) // openid.opEndpoint: "a", openid.opLocalID: "b", openid.claimedID: "c"})
3033
3134 // Make sure we can retrieve them
32- if di := dc .Get ("foo" ); di == nil {
33- t . Errorf ( "Expected a result, got nil" )
34- } else if di . OpEndpoint () != "opEndpoint" || di .OpLocalID () != "opLocalID" || di . ClaimedID () != "claimedID" {
35- t . Errorf ( "Expected opEndpoint opLocalID claimedID, got %v %v %v" , di .OpEndpoint (), di . OpLocalID (), di . ClaimedID ())
36- }
35+ di := dc .Get ("foo" )
36+ require . NotNil ( t , di )
37+ assert . Equal ( t , "opEndpoint" , di .OpEndpoint ())
38+ assert . Equal ( t , "opLocalID" , di .OpLocalID ())
39+ assert . Equal ( t , "claimedID" , di . ClaimedID ())
3740
3841 // Attempt to get a non-existent value
39- if di := dc .Get ("bar" ); di != nil {
40- t .Errorf ("Expected nil, got %v" , di )
41- }
42+ assert .Nil (t , dc .Get ("bar" ))
4243
4344 // Sleep one second and try retrieve again
4445 time .Sleep (1 * time .Second )
4546
46- if di := dc .Get ("foo" ); di != nil {
47- t .Errorf ("Expected a nil, got a result" )
48- }
47+ assert .Nil (t , dc .Get ("foo" ))
4948}
0 commit comments