github.com/Lephar/snapd@v0.0.0-20210825215435-c7fba9cef4d2/cmd/snap/cmd_managed_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2016 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 main_test 21 22 import ( 23 "fmt" 24 "net/http" 25 26 . "gopkg.in/check.v1" 27 28 snap "github.com/snapcore/snapd/cmd/snap" 29 ) 30 31 func (s *SnapSuite) TestManaged(c *C) { 32 for _, managed := range []bool{true, false} { 33 s.stdout.Truncate(0) 34 35 s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) { 36 c.Check(r.Method, Equals, "GET") 37 c.Check(r.URL.Path, Equals, "/v2/system-info") 38 39 fmt.Fprintf(w, `{"type":"sync", "status-code": 200, "result": {"managed":%v}}`, managed) 40 }) 41 42 _, err := snap.Parser(snap.Client()).ParseArgs([]string{"managed"}) 43 c.Assert(err, IsNil) 44 c.Check(s.Stdout(), Equals, fmt.Sprintf("%v\n", managed)) 45 } 46 }