github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/boot/boottest/model.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 boottest 21 22 import ( 23 "github.com/snapcore/snapd/asserts" 24 "github.com/snapcore/snapd/asserts/assertstest" 25 ) 26 27 func MakeMockModel(overrides ...map[string]interface{}) *asserts.Model { 28 headers := map[string]interface{}{ 29 "type": "model", 30 "authority-id": "my-brand", 31 "series": "16", 32 "brand-id": "my-brand", 33 "model": "my-model", 34 "display-name": "My Model", 35 "architecture": "amd64", 36 "base": "core18", 37 "gadget": "pc=18", 38 "kernel": "pc-kernel=18", 39 "timestamp": "2018-01-01T08:00:00+00:00", 40 } 41 return assertstest.FakeAssertion(append([]map[string]interface{}{headers}, overrides...)...).(*asserts.Model) 42 } 43 44 func MakeMockUC20Model(overrides ...map[string]interface{}) *asserts.Model { 45 headers := map[string]interface{}{ 46 "type": "model", 47 "authority-id": "my-brand", 48 "series": "16", 49 "brand-id": "my-brand", 50 "model": "my-model-uc20", 51 "display-name": "My Model", 52 "architecture": "amd64", 53 "base": "core20", 54 "grade": "dangerous", 55 "timestamp": "2019-11-01T08:00:00+00:00", 56 "snaps": []interface{}{ 57 map[string]interface{}{ 58 "name": "pc-kernel", 59 "id": "pckernelidididididididididididid", 60 "type": "kernel", 61 }, 62 map[string]interface{}{ 63 "name": "pc", 64 "id": "pcididididididididididididididid", 65 "type": "gadget", 66 }, 67 }, 68 } 69 return assertstest.FakeAssertion(append([]map[string]interface{}{headers}, overrides...)...).(*asserts.Model) 70 }