func TestCmdMethod(t *testing.T) {
	t.Parallel()
	tests := []struct {
		name   string
		cmd    interface{}
		method string
		err    error
	}{
		{
			name: "unregistered type",
			cmd:  (*int)(nil),
			err:  soterjson.Error{ErrorCode: soterjson.ErrUnregisteredMethod},
		},
		{
			name:   "nil pointer of registered type",
			cmd:    (*soterjson.GetBlockCmd)(nil),
			method: "getblock",
		},
		{
			name:   "nil instance of registered type",
			cmd:    &soterjson.GetBlockCountCmd{},
			method: "getblockcount",
		},
	}
	t.Logf("Running %d tests", len(tests))
	for i, test := range tests {
		method, err := soterjson.CmdMethod(test.cmd)
		if reflect.TypeOf(err) != reflect.TypeOf(test.err) {
			t.Errorf("Test #%d (%s) wrong error - got %T (%[3]v), "+
				"want %T", i, test.name, err, test.err)
			continue
		}
		if err != nil {
			gotErrorCode := err.(soterjson.Error).ErrorCode
			if gotErrorCode != test.err.(soterjson.Error).ErrorCode {
				t.Errorf("Test #%d (%s) mismatched error code "+
					"- got %v (%v), want %v", i, test.name,
					gotErrorCode, err,
					test.err.(soterjson.Error).ErrorCode)
				continue
			}
			continue
		}
		if method != test.method {
			t.Errorf("Test #%d (%s) mismatched method - got %v, "+
				"want %v", i, test.name, method, test.method)
			continue
		}
	}
}
TestCmdMethod tests the CmdMethod function to ensure it retunrs the expected
methods and errors.
package soterjson_test
import (
	"reflect"
	"testing"
	"github.com/soteria-dag/soterd/soterjson"
)