File: patch_go1.17_test.go

package info (click to toggle)
golang-github-frankban-quicktest 1.14.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 332 kB
  • sloc: makefile: 2
file content (36 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (2)
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
31
32
33
34
35
36
// Licensed under the MIT license, see LICENSE file for details.

//go:build !go1.17
// +build !go1.17

package quicktest_test

import (
	"os"
	"testing"

	qt "github.com/frankban/quicktest"
)

const envName = "SOME_VAR"

func TestCSetenv(t *testing.T) {
	c := qt.New(t)
	os.Setenv(envName, "initial")
	testCleanup(t, func(c *qt.C) {
		c.Setenv(envName, "new value")
		c.Check(os.Getenv(envName), qt.Equals, "new value")
	})
	c.Check(os.Getenv(envName), qt.Equals, "initial")
}

func TestCSetenvWithUnsetVariable(t *testing.T) {
	c := qt.New(t)
	os.Unsetenv(envName)
	testCleanup(t, func(c *qt.C) {
		c.Setenv(envName, "new value")
		c.Check(os.Getenv(envName), qt.Equals, "new value")
	})
	_, ok := os.LookupEnv(envName)
	c.Assert(ok, qt.IsFalse)
}