github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/provider/joyent/config_internal_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package joyent 5 6 import ( 7 gc "gopkg.in/check.v1" 8 9 coretesting "github.com/juju/juju/testing" 10 ) 11 12 type InternalSuite struct { 13 coretesting.FakeJujuXDGDataHomeSuite 14 } 15 16 var _ = gc.Suite(&InternalSuite{}) 17 18 func (s *InternalSuite) TestEnsurePrivateKey(c *gc.C) { 19 m := map[string]interface{}{ 20 "private-key": "foo", 21 } 22 23 e := &environConfig{attrs: copymap(m)} 24 25 err := ensurePrivateKey(e) 26 c.Assert(err, gc.IsNil) 27 c.Assert(e.attrs, gc.DeepEquals, m) 28 } 29 30 func (s *InternalSuite) TestEnsurePrivateKeyMissing(c *gc.C) { 31 e := &environConfig{attrs: map[string]interface{}{}} 32 33 err := ensurePrivateKey(e) 34 c.Assert(err, gc.ErrorMatches, "no ssh private key specified in joyent configuration") 35 } 36 37 func copymap(m map[string]interface{}) map[string]interface{} { 38 m1 := make(map[string]interface{}, len(m)) 39 for k, v := range m { 40 m1[k] = v 41 } 42 return m1 43 }