File: fake.go

package info (click to toggle)
golang-collectd 0.5.0%2Bgit20240104.26404de-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 468 kB
  • sloc: ansic: 324; sh: 7; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 728 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
// Package fake implements fake versions of the C functions imported from the
// collectd daemon for testing.
package fake

// void reset_log(void);
// void reset_read(void);
// void reset_shutdown(void);
// void reset_write(void);
//
// int timeout_g = 2;
import "C"

import (
	"time"
)

// TearDown cleans up after a test and prepares shared resources for the next
// test.
//
// Note that this only resets the state of the fake implementations, such as
// "plugin_register_log()". The Go code in "collectd.org/plugin" may still hold
// a reference to the callback even after this function has been called.
func TearDown() {
	SetInterval(10 * time.Second)
	C.reset_log()
	C.reset_read()
	C.reset_shutdown()
	C.reset_write()
}