File: ipforward_linux_test.go

package info (click to toggle)
golang-github-containernetworking-plugins 1.1.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, experimental, forky, sid, trixie
  • size: 1,672 kB
  • sloc: sh: 132; makefile: 11
file content (32 lines) | stat: -rw-r--r-- 830 bytes parent folder | download | duplicates (3)
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
package ip

import (
	"io/ioutil"
	"os"
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("IpforwardLinux", func() {
	It("echo1 must not write the file if content is 1", func() {
		file, err := ioutil.TempFile(os.TempDir(), "containernetworking")
		Expect(err).NotTo(HaveOccurred())
		defer os.Remove(file.Name())
		err = echo1(file.Name())
		Expect(err).NotTo(HaveOccurred())
		statBefore, err := file.Stat()
		Expect(err).NotTo(HaveOccurred())

		// take a duration here, otherwise next file modification operation time
		// will be same as previous one.
		time.Sleep(100 * time.Millisecond)

		err = echo1(file.Name())
		Expect(err).NotTo(HaveOccurred())
		statAfter, err := file.Stat()
		Expect(err).NotTo(HaveOccurred())
		Expect(statBefore.ModTime()).To(Equal(statAfter.ModTime()))
	})
})