當前位置: 首頁>>代碼示例>>Golang>>正文


Golang version.MustParse函數代碼示例

本文整理匯總了Golang中github.com/juju/juju/version.MustParse函數的典型用法代碼示例。如果您正苦於以下問題:Golang MustParse函數的具體用法?Golang MustParse怎麽用?Golang MustParse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了MustParse函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestPerformUpgrade

func (s *upgradeSuite) TestPerformUpgrade(c *gc.C) {
	s.PatchValue(upgrades.UpgradeOperations, upgradeOperations)
	for i, test := range upgradeTests {
		c.Logf("%d: %s", i, test.about)
		var messages []string
		ctx := &mockContext{
			messages: messages,
		}
		fromVersion := version.Zero
		if test.fromVersion != "" {
			fromVersion = version.MustParse(test.fromVersion)
		}
		toVersion := version.MustParse("1.18.0")
		if test.toVersion != "" {
			toVersion = version.MustParse(test.toVersion)
		}
		vers := version.Current
		vers.Number = toVersion
		s.PatchValue(&version.Current, vers)
		err := upgrades.PerformUpgrade(fromVersion, test.target, ctx)
		if test.err == "" {
			c.Check(err, gc.IsNil)
		} else {
			c.Check(err, gc.ErrorMatches, test.err)
		}
		c.Check(ctx.messages, jc.DeepEquals, test.expectedSteps)
	}
}
開發者ID:kapilt,項目名稱:juju,代碼行數:28,代碼來源:upgrade_test.go

示例2: stateUpgradeOperations

func stateUpgradeOperations() []upgrades.Operation {
	steps := []upgrades.Operation{
		&mockUpgradeOperation{
			targetVersion: version.MustParse("1.11.0"),
			steps: []upgrades.Step{
				newUpgradeStep("state step 1 - 1.11.0", upgrades.Controller),
				newUpgradeStep("state step 2 error", upgrades.Controller),
				newUpgradeStep("state step 3 - 1.11.0", upgrades.Controller),
			},
		},
		&mockUpgradeOperation{
			targetVersion: version.MustParse("1.21.0"),
			steps: []upgrades.Step{
				newUpgradeStep("state step 1 - 1.21.0", upgrades.DatabaseMaster),
				newUpgradeStep("state step 2 - 1.21.0", upgrades.Controller),
			},
		},
		&mockUpgradeOperation{
			targetVersion: version.MustParse("1.22.0"),
			steps: []upgrades.Step{
				newUpgradeStep("state step 1 - 1.22.0", upgrades.DatabaseMaster),
				newUpgradeStep("state step 2 - 1.22.0", upgrades.Controller),
			},
		},
	}
	return steps
}
開發者ID:exekias,項目名稱:juju,代碼行數:27,代碼來源:upgrade_test.go

示例3: TestFindToolsExactNotInStorage

func (s *toolsSuite) TestFindToolsExactNotInStorage(c *gc.C) {
	mockToolsStorage := &mockToolsStorage{}
	s.PatchValue(&version.Current, version.MustParse("1.22-beta1"))
	s.testFindToolsExact(c, mockToolsStorage, false, true)
	s.PatchValue(&version.Current, version.MustParse("1.22.0"))
	s.testFindToolsExact(c, mockToolsStorage, false, false)
}
開發者ID:pmatulis,項目名稱:juju,代碼行數:7,代碼來源:tools_test.go

示例4: TestWatchAPIVersion

func (s *machineUpgraderSuite) TestWatchAPIVersion(c *gc.C) {
	w, err := s.st.WatchAPIVersion(s.rawMachine.Tag().String())
	c.Assert(err, jc.ErrorIsNil)
	wc := watchertest.NewNotifyWatcherC(c, w, s.BackingState.StartSync)
	defer wc.AssertStops()

	// Initial event
	wc.AssertOneChange()

	// One change noticing the new version
	vers := version.MustParse("10.20.34")
	err = statetesting.SetAgentVersion(s.BackingState, vers)
	c.Assert(err, jc.ErrorIsNil)
	wc.AssertOneChange()

	// Setting the version to the same value doesn't trigger a change
	err = statetesting.SetAgentVersion(s.BackingState, vers)
	c.Assert(err, jc.ErrorIsNil)
	wc.AssertNoChange()

	// Another change noticing another new version
	vers = version.MustParse("10.20.35")
	err = statetesting.SetAgentVersion(s.BackingState, vers)
	c.Assert(err, jc.ErrorIsNil)
	wc.AssertOneChange()
}
開發者ID:pmatulis,項目名稱:juju,代碼行數:26,代碼來源:upgrader_test.go

示例5: twoDotOhDeprecation

func twoDotOhDeprecation(replacement string) cmd.DeprecationCheck {
	return &versionDeprecation{
		replacement: replacement,
		deprecate:   version.MustParse("2.0-00"),
		obsolete:    version.MustParse("3.0-00"),
	}
}
開發者ID:claudiu-coblis,項目名稱:juju,代碼行數:7,代碼來源:main.go

示例6: TestBlockUpgradeJujuWithRealUpload

func (s *UpgradeJujuSuite) TestBlockUpgradeJujuWithRealUpload(c *gc.C) {
	s.Reset(c)
	s.PatchValue(&version.Current, version.MustParse("1.99.99"))
	cmd := newUpgradeJujuCommand(map[int]version.Number{2: version.MustParse("1.99.99")})
	// Block operation
	s.BlockAllChanges(c, "TestBlockUpgradeJujuWithRealUpload")
	_, err := coretesting.RunCommand(c, cmd, "--upload-tools")
	s.AssertBlocked(c, err, ".*TestBlockUpgradeJujuWithRealUpload.*")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:9,代碼來源:upgradejuju_test.go

示例7: TestPreferredStream

func (s *SimpleStreamsToolsSuite) TestPreferredStream(c *gc.C) {
	for i, test := range preferredStreamTests {
		c.Logf("\ntest %d", i)
		s.PatchValue(&version.Current, version.MustParse(test.currentVers))
		var vers *version.Number
		if test.explicitVers != "" {
			v := version.MustParse(test.explicitVers)
			vers = &v
		}
		obtained := envtools.PreferredStream(vers, test.forceDevel, test.streamInConfig)
		c.Check(obtained, gc.Equals, test.expected)
	}
}
開發者ID:snailwalker,項目名稱:juju,代碼行數:13,代碼來源:tools_test.go

示例8: TestUpgradeJujuWithRealUpload

func (s *UpgradeJujuSuite) TestUpgradeJujuWithRealUpload(c *gc.C) {
	s.Reset(c)
	s.PatchValue(&version.Current, version.MustParse("1.99.99"))
	cmd := newUpgradeJujuCommand(map[int]version.Number{2: version.MustParse("1.99.99")})
	_, err := coretesting.RunCommand(c, cmd, "--upload-tools")
	c.Assert(err, jc.ErrorIsNil)
	vers := version.Binary{
		Number: version.Current,
		Arch:   arch.HostArch(),
		Series: series.HostSeries(),
	}
	vers.Build = 1
	s.checkToolsUploaded(c, vers, vers.Number)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:14,代碼來源:upgradejuju_test.go

示例9: TestSuccess

func (s *EnvironmentVersionSuite) TestSuccess(c *gc.C) {
	vs := "1.22.1"
	s.fake.agentVersion = vs
	v, err := envcmd.GetEnvironmentVersion(s.fake)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(v.Compare(version.MustParse(vs)), gc.Equals, 0)
}
開發者ID:ktsakalozos,項目名稱:juju,代碼行數:7,代碼來源:environmentcommand_test.go

示例10: TestReadConfReadsLegacyFormatAndWritesNew

func (*format_1_16Suite) TestReadConfReadsLegacyFormatAndWritesNew(c *gc.C) {
	dataDir := c.MkDir()
	formatPath := filepath.Join(dataDir, legacyFormatFilename)
	err := utils.AtomicWriteFile(formatPath, []byte(legacyFormatFileContents), 0600)
	c.Assert(err, gc.IsNil)
	configPath := filepath.Join(dataDir, agentConfigFilename)
	err = utils.AtomicWriteFile(configPath, []byte(agentConfig1_16Contents), 0600)
	c.Assert(err, gc.IsNil)

	config, err := ReadConfig(configPath)
	c.Assert(err, gc.IsNil)
	c.Assert(config, gc.NotNil)
	// Test we wrote a currently valid config.
	config, err = ReadConfig(configPath)
	c.Assert(err, gc.IsNil)
	c.Assert(config, gc.NotNil)
	c.Assert(config.UpgradedToVersion(), jc.DeepEquals, version.MustParse("1.16.0"))
	c.Assert(config.Jobs(), gc.HasLen, 0)

	// Old format was deleted.
	assertFileNotExist(c, formatPath)
	// And new contents were written.
	data, err := ioutil.ReadFile(configPath)
	c.Assert(err, gc.IsNil)
	c.Assert(string(data), gc.Not(gc.Equals), agentConfig1_16Contents)
}
開發者ID:rogpeppe,項目名稱:juju,代碼行數:26,代碼來源:format-1.16_whitebox_test.go

示例11: TestStateStepsFor121

func (s *steps121Suite) TestStateStepsFor121(c *gc.C) {
	expected := []string{
		// Settings, and then environment UUID, related migrations should
		// come first as other upgrade steps may rely on them.
		"add the version field to all settings docs",
		"add environment uuid to state server doc",
		"set environment owner and server uuid",
		// It is important to keep the order of the following three steps:
		// 1.migrate machine instanceId, 2. Add env ID to  machine docs, 3.
		// Add env ID to instanceData docs. If the order changes, bad things
		// will happen.
		"migrate machine instanceId into instanceData",
		"prepend the environment UUID to the ID of all machine docs",
		"prepend the environment UUID to the ID of all instanceData docs",
		"prepend the environment UUID to the ID of all containerRef docs",
		"prepend the environment UUID to the ID of all service docs",
		"prepend the environment UUID to the ID of all unit docs",
		"prepend the environment UUID to the ID of all reboot docs",
		"prepend the environment UUID to the ID of all relations docs",
		"prepend the environment UUID to the ID of all relationscopes docs",
		"prepend the environment UUID to the ID of all minUnit docs",
		"prepend the environment UUID to the ID of all cleanup docs",
		"prepend the environment UUID to the ID of all sequence docs",

		// Non-environment UUID upgrade steps follow.
		"rename the user LastConnection field to LastLogin",
		"add all users in state as environment users",
		"migrate custom image metadata into environment storage",
		"migrate tools into environment storage",
		"migrate individual unit ports to openedPorts collection",
		"create entries in meter status collection for existing units",
		"migrate machine jobs into ones with JobManageNetworking based on rules",
	}
	assertStateSteps(c, version.MustParse("1.21.0"), expected)
}
開發者ID:kakamessi99,項目名稱:juju,代碼行數:35,代碼來源:steps121_test.go

示例12: TestMissingAttributes

func (s *format_1_16Suite) TestMissingAttributes(c *gc.C) {
	logDir, err := paths.LogDir(series.HostSeries())
	c.Assert(err, jc.ErrorIsNil)
	realDataDir, err := paths.DataDir(series.HostSeries())
	c.Assert(err, jc.ErrorIsNil)

	realDataDir = filepath.FromSlash(realDataDir)
	logPath := filepath.Join(logDir, "juju")
	logPath = filepath.FromSlash(logPath)

	dataDir := c.MkDir()
	formatPath := filepath.Join(dataDir, legacyFormatFilename)
	err = utils.AtomicWriteFile(formatPath, []byte(legacyFormatFileContents), 0600)
	c.Assert(err, jc.ErrorIsNil)
	configPath := filepath.Join(dataDir, agentConfigFilename)

	err = utils.AtomicWriteFile(configPath, []byte(configDataWithoutNewAttributes), 0600)
	c.Assert(err, jc.ErrorIsNil)
	readConfig, err := ReadConfig(configPath)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(readConfig.UpgradedToVersion(), gc.Equals, version.MustParse("1.16.0"))
	configLogDir := filepath.FromSlash(readConfig.LogDir())
	configDataDir := filepath.FromSlash(readConfig.DataDir())

	c.Assert(configLogDir, gc.Equals, logPath)
	c.Assert(configDataDir, gc.Equals, realDataDir)
	// Test data doesn't include a StateServerKey so StateServingInfo
	// should *not* be available
	_, available := readConfig.StateServingInfo()
	c.Assert(available, jc.IsFalse)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:31,代碼來源:format-1.16_whitebox_test.go

示例13: TestAsJSONBuffer

func (s *metadataSuite) TestAsJSONBuffer(c *gc.C) {
	meta := backups.NewMetadata()
	meta.Origin = backups.Origin{
		Environment: "asdf-zxcv-qwe",
		Machine:     "0",
		Hostname:    "myhost",
		Version:     version.MustParse("1.21-alpha3"),
	}
	meta.Started = time.Date(2014, time.Month(9), 9, 11, 59, 34, 0, time.UTC)

	meta.SetID("20140909-115934.asdf-zxcv-qwe")
	err := meta.MarkComplete(10, "123af2cef")
	c.Assert(err, jc.ErrorIsNil)

	finished := meta.Started.Add(time.Minute)
	meta.Finished = &finished

	buf, err := meta.AsJSONBuffer()
	c.Assert(err, jc.ErrorIsNil)

	c.Check(buf.(*bytes.Buffer).String(), gc.Equals, `{`+
		`"ID":"20140909-115934.asdf-zxcv-qwe",`+
		`"Checksum":"123af2cef",`+
		`"ChecksumFormat":"SHA-1, base64 encoded",`+
		`"Size":10,`+
		`"Stored":"0001-01-01T00:00:00Z",`+
		`"Started":"2014-09-09T11:59:34Z",`+
		`"Finished":"2014-09-09T12:00:34Z",`+
		`"Notes":"",`+
		`"Environment":"asdf-zxcv-qwe",`+
		`"Machine":"0",`+
		`"Hostname":"myhost",`+
		`"Version":"1.21-alpha3"`+
		`}`+"\n")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:35,代碼來源:metadata_test.go

示例14: TestStepsFor125

func (s *steps125Suite) TestStepsFor125(c *gc.C) {
	expected := []string{
		"remove Jujud.pass file on windows",
		"add juju registry key",
	}
	assertSteps(c, version.MustParse("1.25.0"), expected)
}
開發者ID:claudiu-coblis,項目名稱:juju,代碼行數:7,代碼來源:steps125_test.go

示例15: binary

// binary returns the tools metadata's binary version,
// which may be used for map lookup.
func (t *ToolsMetadata) binary() version.Binary {
	return version.Binary{
		Number: version.MustParse(t.Version),
		Series: t.Release,
		Arch:   t.Arch,
	}
}
開發者ID:rogpeppe,項目名稱:juju,代碼行數:9,代碼來源:simplestreams.go


注:本文中的github.com/juju/juju/version.MustParse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。