I have a class i want to test:
type ApiGateway struct {
username string
password string
scsClient *scsClient.APIDocumentation
auth Auth
}
type Auth struct {
token string
validTo int32
}
func New(host string, scheme string, username string, password string) *ApiGateway {
var config = scsClient.TransportConfig{host, "/", []string{scheme}}
var client = scsClient.NewHTTPClientWithConfig(strfmt.Default, &config)
return &ApiGateway{username, password, client, Auth{}}
}
func (s *ApiGateway) isTokenValid() bool { ... }
This isTokenValid method is called from every other method inside the class in order to verify and/or update the API token. In tests I want to mock this method, so it always returns true for example.
How do I archieve that?
Aucun commentaire:
Enregistrer un commentaire