Skip to content

Commit

Permalink
add $LATEST
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Sep 4, 2023
1 parent e6e429b commit bca246c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lambroll_test

import (
"encoding/json"
"strings"
"testing"
"time"

Expand All @@ -15,6 +16,7 @@ var TestFixedTime = time.Date(2023, 8, 30, 12, 34, 56, 0, time.FixedZone("Asia/T
var TestVersionsOutputs = lambroll.VersionsOutputs{
{Version: "1", LastModified: TestFixedTime, PackageType: "Zip", Runtime: "provided.al2"},
{Version: "2", LastModified: TestFixedTime, PackageType: "Image", Runtime: "", Aliases: []string{"current", "latest"}},
{Version: "$LATEST", LastModified: TestFixedTime, PackageType: "Zip", Runtime: "provided.al2"},
}

func TestVersionsJSON(t *testing.T) {
Expand All @@ -34,8 +36,12 @@ func TestVersionsJSON(t *testing.T) {

func TestVersionsTSV(t *testing.T) {
t.Setenv("TZ", "UTC+9")
expectedTSV := "1\t2023-08-30T12:34:56+09:00\t\tZip\tprovided.al2\n" +
"2\t2023-08-30T12:34:56+09:00\tcurrent,latest\tImage\t\n"
expectedTSV := strings.Join([]string{
"1\t2023-08-30T12:34:56+09:00\t\tZip\tprovided.al2",
"2\t2023-08-30T12:34:56+09:00\tcurrent,latest\tImage\t",
"$LATEST\t2023-08-30T12:34:56+09:00\t\tZip\tprovided.al2",
}, "\n")
expectedTSV += "\n"

if d := cmp.Diff(TestVersionsOutputs.TSV(), expectedTSV); d != "" {
t.Errorf("TSV mismatch: diff:%s", d)
Expand All @@ -51,6 +57,7 @@ func TestVersionsTable(t *testing.T) {
+---------+---------------------------+----------------+--------------+--------------+
| 1 | 2023-08-30T12:34:56+09:00 | | Zip | provided.al2 |
| 2 | 2023-08-30T12:34:56+09:00 | current,latest | Image | |
| $LATEST | 2023-08-30T12:34:56+09:00 | | Zip | provided.al2 |
+---------+---------------------------+----------------+--------------+--------------+
`
expectedOutput = expectedOutput[1:] // remove first newline
Expand Down

0 comments on commit bca246c

Please sign in to comment.