github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/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  type DoOptions = doOptions
    34  
    35  // Do does do.
    36  func (client *Client) Do(method, path string, query url.Values, body io.Reader, v interface{}, opts *DoOptions) (statusCode int, err error) {
    37  	return client.do(method, path, query, nil, body, v, opts)
    38  }
    39  
    40  // expose parseError for testing
    41  var ParseErrorInTest = parseError
    42  
    43  // expose read and write auth helpers for testing
    44  var TestWriteAuth = writeAuthData
    45  var TestReadAuth = readAuthData
    46  var TestStoreAuthFilename = storeAuthDataFilename
    47  
    48  var TestAuthFileEnvKey = authFileEnvKey
    49  
    50  func UnmarshalSnapshotAction(body io.Reader) (act snapshotAction, err error) {
    51  	err = json.NewDecoder(body).Decode(&act)
    52  	return
    53  }
    54  
    55  type DownloadAction = downloadAction