...

Source file src/github.com/letsencrypt/boulder/rocsp/mocks.go

Documentation: github.com/letsencrypt/boulder/rocsp

     1  package rocsp
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"golang.org/x/crypto/ocsp"
     8  )
     9  
    10  // MockWriteClient is a mock
    11  type MockWriteClient struct {
    12  	StoreReponseReturnError error
    13  }
    14  
    15  // StoreResponse mocks a rocsp.StoreResponse method and returns nil or an
    16  // error depending on the desired state.
    17  func (r MockWriteClient) StoreResponse(ctx context.Context, resp *ocsp.Response) error {
    18  	return r.StoreReponseReturnError
    19  }
    20  
    21  // NewMockWriteSucceedClient returns a mock MockWriteClient with a
    22  // StoreResponse method that will always succeed.
    23  func NewMockWriteSucceedClient() MockWriteClient {
    24  	return MockWriteClient{nil}
    25  }
    26  
    27  // NewMockWriteFailClient returns a mock MockWriteClient with a
    28  // StoreResponse method that will always fail.
    29  func NewMockWriteFailClient() MockWriteClient {
    30  	return MockWriteClient{StoreReponseReturnError: fmt.Errorf("could not store response")}
    31  }
    32  

View as plain text