github.com/Lephar/snapd@v0.0.0-20210825215435-c7fba9cef4d2/overlord/configstate/settings/settings_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2018 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 settings_test
    21  
    22  import (
    23  	"testing"
    24  
    25  	. "gopkg.in/check.v1"
    26  
    27  	"github.com/snapcore/snapd/overlord/configstate/config"
    28  	"github.com/snapcore/snapd/overlord/configstate/settings"
    29  	"github.com/snapcore/snapd/overlord/state"
    30  )
    31  
    32  func TestT(t *testing.T) { TestingT(t) }
    33  
    34  type settingsSuite struct {
    35  	state *state.State
    36  }
    37  
    38  var _ = Suite(&settingsSuite{})
    39  
    40  func (s *settingsSuite) SetUpTest(c *C) {
    41  	s.state = state.New(nil)
    42  }
    43  
    44  func (s *settingsSuite) TestSettingProblemReportsDisableDefault(c *C) {
    45  	s.state.Lock()
    46  	defer s.state.Unlock()
    47  
    48  	c.Check(settings.ProblemReportsDisabled(s.state), Equals, false)
    49  }
    50  
    51  func (s *settingsSuite) TestSettingProblemReportsDisable(c *C) {
    52  	s.state.Lock()
    53  	defer s.state.Unlock()
    54  
    55  	tr := config.NewTransaction(s.state)
    56  	tr.Set("core", "problem-reports.disabled", true)
    57  	tr.Commit()
    58  
    59  	c.Check(settings.ProblemReportsDisabled(s.state), Equals, true)
    60  }