twitter

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2023 License: MIT

README

codecov Go Report Card

Testing

You should mock dependencies using following way with minimock library:

func Test_Template(t *testing.T) {
    var (
        _ = "fake variable"
    )

    type mocks struct {
        // *mock.OneMock
        // *mock.TwoMock
    }
    testCases := []struct {
        name string
        // your args
        expect func(mocks)
        // want value
        wantError bool
    }{
        {},
    }

    for _, tc := range testCases {
        tc := tc
        t.Run(tc.name, func(t *testing.T) {
            t.Parallel()
            mc := minimock.NewController(t)
            defer mc.Finish()
            m := mocks{
                // mock.NewOneMock(mc), mock.NewTwoMock(mc),
            }
            tc.expect(m)

            s := &some{
                // one: m.OneMock, // two: m.TwoMock
            }
            err := s.CallMethod(tc.arg)
            assert.Equal(t, tc.wantError, err != nil, "not expected error: %v", err)
        })
    }
}

Directories

Path Synopsis
cmd
internal
pkg
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL