github.com/rigado/snapd@v2.42.5-go-mod+incompatible/overlord/snapstate/models_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2016-2019 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 snapstate_test
    21  
    22  import (
    23  	"github.com/snapcore/snapd/asserts"
    24  	"github.com/snapcore/snapd/asserts/assertstest"
    25  )
    26  
    27  func ModelWithBase(baseName string) *asserts.Model {
    28  	return MakeModel(map[string]interface{}{"base": baseName})
    29  }
    30  
    31  func ModelWithKernelTrack(kernelTrack string) *asserts.Model {
    32  	return MakeModel(map[string]interface{}{"kernel": "kernel=" + kernelTrack})
    33  }
    34  
    35  func ModelWithGadgetTrack(gadgetTrack string) *asserts.Model {
    36  	return MakeModel(map[string]interface{}{"gadget": "brand-gadget=" + gadgetTrack})
    37  }
    38  
    39  func DefaultModel() *asserts.Model {
    40  	return MakeModel(nil)
    41  }
    42  
    43  func MakeModel(override map[string]interface{}) *asserts.Model {
    44  	model := map[string]interface{}{
    45  		"type":         "model",
    46  		"authority-id": "brand",
    47  		"series":       "16",
    48  		"brand-id":     "brand",
    49  		"model":        "baz-3000",
    50  		"architecture": "armhf",
    51  		"gadget":       "brand-gadget",
    52  		"kernel":       "kernel",
    53  		"timestamp":    "2018-01-01T08:00:00+00:00",
    54  	}
    55  	return assertstest.FakeAssertion(model, override).(*asserts.Model)
    56  }
    57  
    58  func ClassicModel() *asserts.Model {
    59  	headers := map[string]interface{}{
    60  		"type":         "model",
    61  		"authority-id": "brand",
    62  		"series":       "16",
    63  		"brand-id":     "brand",
    64  		"model":        "classicbaz-3000",
    65  		"classic":      "true",
    66  		"timestamp":    "2018-01-01T08:00:00+00:00",
    67  	}
    68  	return assertstest.FakeAssertion(headers).(*asserts.Model)
    69  }