Skip to content

Commit

Permalink
Move fixtures to testdata folder
Browse files Browse the repository at this point in the history
This prevents the test fixtures from being shipped around in the module
cache. ie. Prior if project A has a dependency on this project then running
`go mod vendor` will pull the fixtures.ttar into the vendor folder

Signed-off-by: dprotaso <dprotaso@gmail.com>
  • Loading branch information
dprotaso committed May 4, 2022
1 parent b9b5ad9 commit b63c923
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 7,980 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1 +1,2 @@
/fixtures/
/testdata/fixtures/
/fixtures
10 changes: 5 additions & 5 deletions Makefile
Expand Up @@ -14,18 +14,18 @@
include Makefile.common

%/.unpacked: %.ttar
@echo ">> extracting fixtures"
@echo ">> extracting fixtures $*"
./ttar -C $(dir $*) -x -f $*.ttar
touch $@

fixtures: fixtures/.unpacked
fixtures: testdata/fixtures/.unpacked

update_fixtures:
rm -vf fixtures/.unpacked
./ttar -c -f fixtures.ttar fixtures/
rm -vf testdata/fixtures/.unpacked
./ttar -c -f testdata/fixtures.ttar -C testdata/ fixtures/

.PHONY: build
build:

.PHONY: test
test: fixtures/.unpacked common-test
test: testdata/fixtures/.unpacked common-test
2 changes: 1 addition & 1 deletion bcache/get_test.go
Expand Up @@ -19,7 +19,7 @@ import (
)

func TestFSBcacheStats(t *testing.T) {
bcache, err := NewFS("../fixtures/sys")
bcache, err := NewFS("testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access bcache fs: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions bcache/testdata/fixtures
10 changes: 5 additions & 5 deletions blockdevice/stats_test.go
Expand Up @@ -21,8 +21,8 @@ import (

const (
failMsgFormat = "%v, expected %v, actual %v"
procfsFixtures = "../fixtures/proc"
sysfsFixtures = "../fixtures/sys"
procfsFixtures = "testdata/fixtures/proc"
sysfsFixtures = "testdata/fixtures/sys"
)

func TestDiskstats(t *testing.T) {
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestDiskstats(t *testing.T) {
}

func TestBlockDevice(t *testing.T) {
blockdevice, err := NewFS("../fixtures/proc", "../fixtures/sys")
blockdevice, err := NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access blockdevice fs: %v", err)
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestBlockDevice(t *testing.T) {
}

func TestBlockDmInfo(t *testing.T) {
blockdevice, err := NewFS("../fixtures/proc", "../fixtures/sys")
blockdevice, err := NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access blockdevice fs: %v", err)
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestBlockDmInfo(t *testing.T) {
}

func TestSysBlockDeviceUnderlyingDevices(t *testing.T) {
blockdevice, err := NewFS("../fixtures/proc", "../fixtures/sys")
blockdevice, err := NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access blockdevice fs: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions blockdevice/testdata/fixtures
2 changes: 1 addition & 1 deletion btrfs/get_test.go
Expand Up @@ -28,7 +28,7 @@ type alloc struct {
}

func TestFSBtrfsStats(t *testing.T) {
btrfs, err := NewFS("../fixtures/sys")
btrfs, err := NewFS("testdata/fixtures/sys")
if err != nil {
t.Fatalf("failed to access Btrfs filesystem: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions btrfs/testdata/fixtures

0 comments on commit b63c923

Please sign in to comment.