Merge pull request #217547 from cideM/go-migrate-tests
go-mockery: add package test
This commit is contained in:
commit
324ef866e2
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildGoModule, fetchFromGitHub }:
|
{ lib, buildGoModule, fetchFromGitHub, go-mockery, runCommand, go }:
|
||||||
|
|
||||||
buildGoModule rec {
|
buildGoModule rec {
|
||||||
pname = "go-mockery";
|
pname = "go-mockery";
|
||||||
|
@ -24,6 +24,37 @@ buildGoModule rec {
|
||||||
|
|
||||||
vendorHash = "sha256-3lx3wHnPQ/slRXnlVAnI1ZqSykDXNivjwg1WUITGj64=";
|
vendorHash = "sha256-3lx3wHnPQ/slRXnlVAnI1ZqSykDXNivjwg1WUITGj64=";
|
||||||
|
|
||||||
|
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; {
|
meta = with lib; {
|
||||||
homepage = "https://github.com/vektra/mockery";
|
homepage = "https://github.com/vektra/mockery";
|
||||||
description = "A mock code autogenerator for Golang";
|
description = "A mock code autogenerator for Golang";
|
||||||
|
|
Loading…
Reference in a new issue