golang.org/x/build@v0.0.0-20240506185731-218518f32b70/cmd/relnote/todo_test.go (about) 1 // Copyright 2024 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "bytes" 9 "testing" 10 "testing/fstest" 11 "time" 12 ) 13 14 func TestToDo(t *testing.T) { 15 files := map[string]string{ 16 "a.md": "TODO: write something", 17 "b.md": "nothing to do", 18 "c": "has a TODO but not a .md file", 19 } 20 21 dir := fstest.MapFS{} 22 for name, contents := range files { 23 dir[name] = &fstest.MapFile{Data: []byte(contents)} 24 } 25 var buf bytes.Buffer 26 if err := todo(&buf, dir, time.Time{}); err != nil { 27 t.Fatal(err) 28 } 29 got := buf.String() 30 want := `TODO: write something (from a.md:1) 31 ` 32 if got != want { 33 t.Errorf("\ngot:\n%s\nwant:\n%s", got, want) 34 } 35 }