Mockery in golang

This library is used for testing in golang



Installation

go get github.com/vektra/mockery/...

if happened errors then types

go get github.com/vektra/mockery/cmd/mockery
package test

type Stringer interface {
 String() string
}


Run: mockery -name=Stringer and the following will be output to mocks/Stringer.go:
package mocks

import "github.com/stretchr/testify/mock"

type Stringer struct {
 mock.Mock
}

func (m *Stringer) String() string {
 ret := m.Called()

 var r0 string
 if rf, ok := ret.Get(0).(func() string); ok {
  r0 = rf()
 } else {
  r0 = ret.Get(0).(string)
 }

 return r0
}

Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch