コード例 #1
0
ファイル: parser_test.go プロジェクト: aws/amazon-ssm-agent
func parsePluginResult(t *testing.T, pluginRuntimeStatus contracts.PluginRuntimeStatus) contracts.PluginResult {
	parsedOutput := pluginRuntimeStatus.Output
	return contracts.PluginResult{
		Output:        parsedOutput,
		Status:        pluginRuntimeStatus.Status,
		StartDateTime: times.ParseIso8601UTC(pluginRuntimeStatus.StartDateTime),
		EndDateTime:   times.ParseIso8601UTC(pluginRuntimeStatus.EndDateTime),
	}
}
コード例 #2
0
ファイル: parser_test.go プロジェクト: aws/amazon-ssm-agent
func TestPrepareReplyPayload(t *testing.T) {
	type testCase struct {
		PluginRuntimeStatuses map[string]*contracts.PluginRuntimeStatus
		DateTime              time.Time
		Agent                 contracts.AgentInfo
		Result                messageContracts.SendReplyPayload
	}

	// generate test cases
	var testCases []testCase
	for _, fileName := range sampleMessageReplyFiles {
		// parse a test reply to see if we can regenerate it
		expectedReply := loadMessageReplyFromFile(t, fileName)

		testCases = append(testCases, testCase{
			PluginRuntimeStatuses: expectedReply.RuntimeStatus,
			DateTime:              times.ParseIso8601UTC(expectedReply.AdditionalInfo.DateTime),
			Agent:                 expectedReply.AdditionalInfo.Agent,
			Result:                expectedReply,
		})
	}

	// run test cases
	for _, tst := range testCases {
		// call our method under test
		docResult := PrepareReplyPayload("", tst.PluginRuntimeStatuses, tst.DateTime, tst.Agent)

		// check result
		assert.Equal(t, tst.Result, docResult)
	}
}