File: setup_test.go

package info (click to toggle)
golang-github-rogpeppe-go-internal 1.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,184 kB
  • sloc: makefile: 6
file content (30 lines) | stat: -rw-r--r-- 561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package gotooltest

import (
	"os"
	"testing"
)

func TestInitGoEnv(t *testing.T) {
	// Set up a temp directory containing a bad go.mod file to
	// ensure the working directory does not influence the probe
	// commands run during initGoEnv
	td := t.TempDir()

	// If these commands fail we are in bigger trouble
	wd, _ := os.Getwd()
	os.Chdir(td)

	t.Cleanup(func() {
		os.Chdir(wd)
		os.Remove(td)
	})

	if err := os.WriteFile("go.mod", []byte("this is rubbish"), 0600); err != nil {
		t.Fatal(err)
	}

	if err := initGoEnv(); err != nil {
		t.Fatal(err)
	}
}