package main

import (
	"reflect"
	"testing"
)

func TestGetMetadataProvider(t *testing.T) {
	tests := []struct {
		desc string
		name string
		err  error
	}{
		{
			desc: "supported provider",
			name: "digitalocean",
			err:  nil,
		},
		{
			desc: "unknown provider",
			name: "not-supported",
			err:  ErrUnknownProvider,
		},
		{
			desc: "empty provider",
			name: "",
			err:  ErrUnknownProvider,
		},
	}

	for _, tt := range tests {
		_, err := getMetadataProvider(tt.name)
		if !reflect.DeepEqual(err, tt.err) {
			t.Errorf("%s:\nwant: %v\n got: %v", tt.desc, tt.err, err)
		}
	}
}

package main

import (
	"errors"
	"reflect"
	"testing"
)

func TestGetMetadataProvider(t *testing.T) {
	tests := []struct {
		desc string
		name string
		err  error
	}{
		{
			desc: "supported provider",
			name: "digitalocean",
			err:  nil,
		},
		{
			desc: "unknown provider",
			name: "not-supported",
			err:  errors.New("unknown provider"),
		},
		{
			desc: "empty provider",
			name: "",
			err:  errors.New("unknown provider"),
		},
	}

	for _, tt := range tests {
		_, err := getMetadataProvider(tt.name)
		if !reflect.DeepEqual(err, tt.err) {
			t.Errorf("%s:\nwant: %v\n got: %v", tt.desc, tt.err, err)
		}
	}
}

--- 
+++ 
@@ -1,7 +1,6 @@
 package main
 
 import (
-	"errors"
 	"reflect"
 	"testing"
 )
@@ -20,12 +19,12 @@
 		{
 			desc: "unknown provider",
 			name: "not-supported",
-			err:  errors.New("unknown provider"),
+			err:  ErrUnknownProvider,
 		},
 		{
 			desc: "empty provider",
 			name: "",
-			err:  errors.New("unknown provider"),
+			err:  ErrUnknownProvider,
 		},
 	}
 
internal: Use ErrUnknownProvider in tests as well
