blob: 36379a520899c33d052143aabafeeac609399a68 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
{ lib, buildGoModule, fetchFromGitHub, go-mockery, runCommand, go }:
buildGoModule rec {
pname = "go-mockery";
version = "2.35.2";
src = fetchFromGitHub {
owner = "vektra";
repo = "mockery";
rev = "v${version}";
sha256 = "sha256-MsaAITGFDnAylxMU+PGbSl+H/W/Y7pghBbfQyqp31AM=";
};
preCheck = ''
substituteInPlace ./pkg/generator_test.go --replace 0.0.0-dev ${version}
substituteInPlace ./pkg/logging/logging_test.go --replace v0.0 v${lib.versions.majorMinor version}
'';
ldflags = [
"-s" "-w"
"-X" "github.com/vektra/mockery/v2/pkg/logging.SemVer=v${version}"
];
CGO_ENABLED = false;
proxyVendor = true;
vendorHash = "sha256-HxxtKtjc1EuONG4bYTZc9i40X6Q75bQzV1Wi6Qb/Id0=";
passthru.tests = {
generateMock = runCommand "${pname}-test" {
nativeBuildInputs = [ go-mockery ];
buildInputs = [ go ];
} ''
if [[ $(mockery --version) != *"${version}"* ]]; then
echo "Error: program version does not match package version"
exit 1
fi
export HOME=$TMPDIR
cat <<EOF > foo.go
package main
type Foo interface {
Bark() string
}
EOF
mockery --name Foo --dir .
if [[ ! -f "mocks/Foo.go" ]]; then
echo "Error: mocks/Foo.go was not generated by ${pname}"
exit 1
fi
touch $out
'';
};
meta = with lib; {
homepage = "https://github.com/vektra/mockery";
description = "A mock code autogenerator for Golang";
maintainers = with maintainers; [ fbrs ];
mainProgram = "mockery";
license = licenses.bsd3;
};
}
|