File: export_test.go

package info (click to toggle)
golang-github-juju-utils 0.0~git20200923.4646bfe-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,324 kB
  • sloc: makefile: 37
file content (39 lines) | stat: -rw-r--r-- 906 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
33
34
35
36
37
38
39
// Copyright 2013 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.

package ssh

import (
	"sync/atomic"

	gc "gopkg.in/check.v1"

	"github.com/juju/testing"
)

var (
	ReadAuthorisedKeys  = readAuthorisedKeys
	WriteAuthorisedKeys = writeAuthorisedKeys
	InitDefaultClient   = initDefaultClient
	DefaultIdentities   = &defaultIdentities
	SSHDial             = &sshDial
	RSAGenerateKey      = &rsaGenerateKey
	TestCopyReader      = copyReader
	TestNewCmd          = newCmd
)

type ReadLineWriter readLineWriter

func PatchTerminal(s *testing.CleanupSuite, rlw ReadLineWriter) {
	var balance int64
	s.PatchValue(&getTerminal, func() (readLineWriter, func(), error) {
		atomic.AddInt64(&balance, 1)
		cleanup := func() {
			atomic.AddInt64(&balance, -1)
		}
		return rlw, cleanup, nil
	})
	s.AddCleanup(func(c *gc.C) {
		c.Assert(atomic.LoadInt64(&balance), gc.Equals, int64(0))
	})
}