@@ -24,36 +24,42 @@ func TestInstanceExistsByProviderID(t *testing.T) {
2424 instances := newInstances (client )
2525
2626 t .Run ("should propagate generic api error" , func (t * testing.T ) {
27- providerID := providerIDPrefix + "123"
27+ node := & v1.Node {Spec : v1.NodeSpec {
28+ ProviderID : providerIDPrefix + "123" ,
29+ }}
2830 expectedErr := errors .New ("some error" )
2931 client .EXPECT ().GetInstance (gomock .Any (), 123 ).Times (1 ).Return (nil , expectedErr )
3032
31- exists , err := instances .InstanceExistsByProviderID (ctx , providerID )
33+ exists , err := instances .InstanceExists (ctx , node )
3234 assert .ErrorIs (t , err , expectedErr )
3335 assert .False (t , exists )
3436 })
3537
3638 t .Run ("should return false if linode does not exist" , func (t * testing.T ) {
37- providerID := providerIDPrefix + "123"
39+ node := & v1.Node {Spec : v1.NodeSpec {
40+ ProviderID : providerIDPrefix + "123" ,
41+ }}
3842 client .EXPECT ().GetInstance (gomock .Any (), 123 ).Times (1 ).Return (nil , & linodego.Error {
3943 Code : http .StatusNotFound ,
4044 })
4145
42- exists , err := instances .InstanceExistsByProviderID (ctx , providerID )
46+ exists , err := instances .InstanceExists (ctx , node )
4347 assert .NoError (t , err )
4448 assert .False (t , exists )
4549 })
4650
4751 t .Run ("should return true if linode exists" , func (t * testing.T ) {
48- providerID := providerIDPrefix + "123"
52+ node := & v1.Node {Spec : v1.NodeSpec {
53+ ProviderID : providerIDPrefix + "123" ,
54+ }}
4955 client .EXPECT ().GetInstance (gomock .Any (), 123 ).Times (1 ).Return (& linodego.Instance {
5056 ID : 123 ,
5157 Label : "mock" ,
5258 Region : "us-east" ,
5359 Type : "g6-standard-2" ,
5460 }, nil )
5561
56- exists , err := instances .InstanceExistsByProviderID (ctx , providerID )
62+ exists , err := instances .InstanceExists (ctx , node )
5763 assert .NoError (t , err )
5864 assert .True (t , exists )
5965 })
0 commit comments