Skip to content

Commit

Permalink
Fix plugin modules and test make target
Browse files Browse the repository at this point in the history
  • Loading branch information
prskr committed Apr 11, 2020
1 parent 8134110 commit ac067cd
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 16 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ VERSION = $(shell git describe --dirty --tags --always)
DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
BUILD_PATH = $(DIR)/main.go
PKGS = $(shell go list ./...)
TEST_PKGS = $(shell find . -type f -name "*_test.go" -printf '%h\n' | sort -u)
TEST_PKGS = $(shell find . -type f -name "*_test.go" -not -path "./pkg/plugins/*" -printf '%h\n' | sort -u)
GOARGS = GOOS=linux GOARCH=amd64
GO_BUILD_ARGS = -ldflags="-w -s"
GO_CONTAINER_BUILD_ARGS = -ldflags="-w -s" -a -installsuffix cgo
Expand All @@ -13,7 +13,7 @@ DEBUG_PORT = 2345
DEBUG_ARGS?= --development-logs=true
INETMOCK_PLUGINS_DIRECTORY = $(DIR)

.PHONY: clean all format deps compile debug test cli-cover-report html-cover-report plugins $(PLUGINS)
.PHONY: clean all format deps compile debug snapshot-release test cli-cover-report html-cover-report plugins $(PLUGINS)

all: clean format compile test plugins

Expand Down Expand Up @@ -49,6 +49,10 @@ debug:
--api-version=2 \
--accept-multiclient \
-- $(DEBUG_ARGS)

snapshot-release:
@goreleaser release --snapshot --skip-publish --rm-dist

test:
@go test -coverprofile=./cov-raw.out -v $(TEST_PKGS)
@cat ./cov-raw.out | grep -v "generated" > ./cov.out
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ module github.com/baez90/inetmock
go 1.13

require (
github.com/miekg/dns v1.1.29
github.com/spf13/cobra v0.0.6
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.4.0
go.uber.org/zap v1.14.1
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe // indirect
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.1.29 h1:xHBEhR+t5RzcFJjBLJlax2daXOrTYtr9z4WdKEfWFzg=
github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
Expand Down Expand Up @@ -146,8 +144,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
54 changes: 54 additions & 0 deletions pkg/path/helpers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package path

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"path"
"testing"
)

func TestFileExists(t *testing.T) {

tmpFile, err := ioutil.TempFile("", "inetmock")

if err != nil {
t.Errorf("failed to create temp file: %v", err)
}
defer func() {
tmpFile.Close()
os.Remove(tmpFile.Name())
}()

type args struct {
filename string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "Ensure temp file exists",
want: true,
args: args{
filename: tmpFile.Name(),
},
},
{
name: "Ensure random file name does not exist",
want: false,
args: args{
filename: path.Join(os.TempDir(), fmt.Sprintf("asdf-%d", rand.Uint32())),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FileExists(tt.args.filename); got != tt.want {
t.Errorf("FileExists() = %v, want %v", got, tt.want)
}
})
}
}
12 changes: 11 additions & 1 deletion pkg/plugins/dns_mock/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ module github.com/baez90/inetmock/pkg/plugins/dns_mock
go 1.14

require (
github.com/baez90/inetmock v0.0.0-20200411101945-d8b7cfa1a206 // indirect
github.com/baez90/inetmock v0.0.0-20200411110422-813411044f8b
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/miekg/dns v1.1.29
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.0.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.6.3
go.uber.org/zap v1.14.1
golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/ini.v1 v1.55.0 // indirect
)
Loading

0 comments on commit ac067cd

Please sign in to comment.