github.com/rigado/snapd@v2.42.5-go-mod+incompatible/client/export_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2015 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package client 21 22 import ( 23 "encoding/json" 24 "io" 25 "net/url" 26 ) 27 28 // SetDoer sets the client's doer to the given one 29 func (client *Client) SetDoer(d doer) { 30 client.doer = d 31 } 32 33 // Do does do. 34 func (client *Client) Do(method, path string, query url.Values, body io.Reader, v interface{}) (statusCode int, err error) { 35 return client.do(method, path, query, nil, body, v) 36 } 37 38 // expose parseError for testing 39 var ParseErrorInTest = parseError 40 41 // expose read and write auth helpers for testing 42 var TestWriteAuth = writeAuthData 43 var TestReadAuth = readAuthData 44 var TestStoreAuthFilename = storeAuthDataFilename 45 46 var TestAuthFileEnvKey = authFileEnvKey 47 48 func UnmarshalSnapshotAction(body io.Reader) (act snapshotAction, err error) { 49 err = json.NewDecoder(body).Decode(&act) 50 return 51 }