github.com/david-imola/snapd@v0.0.0-20210611180407-2de8ddeece6d/client/console_conf_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2020 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_test
    21  
    22  import (
    23  	. "gopkg.in/check.v1"
    24  )
    25  
    26  func (cs *clientSuite) TestClientInternalConsoleConfEndpointEmpty(c *C) {
    27  	// no changes and no snaps
    28  	cs.status = 200
    29  	cs.rsp = `{
    30  		"type": "sync",
    31  		"status-code": 200,
    32          "result": {}
    33  	}`
    34  
    35  	chgs, snaps, err := cs.cli.InternalConsoleConfStart()
    36  	c.Assert(chgs, HasLen, 0)
    37  	c.Assert(snaps, HasLen, 0)
    38  	c.Assert(err, IsNil)
    39  	c.Check(cs.req.Method, Equals, "POST")
    40  	c.Check(cs.req.URL.Path, Equals, "/v2/internal/console-conf-start")
    41  	c.Check(cs.doCalls, Equals, 1)
    42  }
    43  
    44  func (cs *clientSuite) TestClientInternalConsoleConfEndpoint(c *C) {
    45  	// some changes and snaps
    46  	cs.status = 200
    47  	cs.rsp = `{
    48  		"type": "sync",
    49  		"status-code": 200,
    50          "result": {
    51  			"active-auto-refreshes": ["1"],
    52  			"active-auto-refresh-snaps": ["pc-kernel"]
    53  		}
    54  	}`
    55  
    56  	chgs, snaps, err := cs.cli.InternalConsoleConfStart()
    57  	c.Assert(err, IsNil)
    58  	c.Assert(chgs, DeepEquals, []string{"1"})
    59  	c.Assert(snaps, DeepEquals, []string{"pc-kernel"})
    60  	c.Check(cs.req.Method, Equals, "POST")
    61  	c.Check(cs.req.URL.Path, Equals, "/v2/internal/console-conf-start")
    62  	c.Check(cs.doCalls, Equals, 1)
    63  }