예제 #1
0
func toCronResult(record map[string]*dynamodb.AttributeValue) CronResult {
	result := CronResult{}
	result.Key = aws.DynamoS(record, "Key")
	result.Memo = aws.DynamoS(record, "Memo")
	result.LastStartDate = misc.StringToTime(aws.DynamoS(record, "LastStartDate"))
	result.LastEndDate = misc.StringToTime(aws.DynamoS(record, "LastEndDate"))
	return result
}
예제 #2
0
func TestToCronResult(t *testing.T) {
	actual := toCronResult(map[string]*dynamodb.AttributeValue{
		"Key": &dynamodb.AttributeValue{
			S: awssdk.String("key-name"),
		},
		"LastStartDate": &dynamodb.AttributeValue{
			S: awssdk.String("2015-08-01T12:03:04Z"),
		},
		"LastEndDate": &dynamodb.AttributeValue{
			S: awssdk.String("2015-08-02T23:45:06+0900"),
		},
	})
	expected := CronResult{}
	expected.Key = "key-name"
	expected.LastStartDate = misc.StringToTime("2015-08-01T12:03:04Z")
	expected.LastEndDate = misc.StringToTime("2015-08-02T23:45:06+0900")

	if !reflect.DeepEqual(actual, expected) {
		t.Errorf("Expected %v, but got %v", expected, actual)
		return
	}
}