From 90c924ff88a8b5ab65538ccc16d160922b1b4003 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 6 Jul 2020 10:58:05 -0400 Subject: testing/fstest: new package for testing file system code This change adds basic test helpers for file system code. The type MapFS is a simple map-based file system for use when exercising general file system code. The func TestFS tests a file system implementation. For #41190. Change-Id: I5a2036f57e733915ad508651ad7317749794423c Reviewed-on: https://go-review.googlesource.com/c/go/+/243910 Trust: Russ Cox Reviewed-by: Rob Pike --- src/testing/fstest/mapfs_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/testing/fstest/mapfs_test.go (limited to 'src/testing/fstest/mapfs_test.go') diff --git a/src/testing/fstest/mapfs_test.go b/src/testing/fstest/mapfs_test.go new file mode 100644 index 0000000000..2abedd6735 --- /dev/null +++ b/src/testing/fstest/mapfs_test.go @@ -0,0 +1,19 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fstest + +import ( + "testing" +) + +func TestMapFS(t *testing.T) { + m := MapFS{ + "hello": {Data: []byte("hello, world\n")}, + "fortune/k/ken.txt": {Data: []byte("If a program is too slow, it must have a loop.\n")}, + } + if err := TestFS(m, "hello", "fortune/k/ken.txt"); err != nil { + t.Fatal(err) + } +} -- cgit v1.3