Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/cli/internal/cli/changelog/metadata/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package metadata
import (
"encoding/json"
"fmt"
"strings"
"time"

"github.com/mongodb/openapi/tools/cli/internal/changelog"
Expand Down Expand Up @@ -71,6 +72,9 @@ func (o *Opts) PreRun() error {
}

for _, version := range o.versions {
if strings.Contains(version, ".upcoming") {
continue
}
if _, err := time.Parse("2006-01-02", version); err != nil {
return fmt.Errorf("invalid version date: %w. Make sure to use the format YYYY-MM-DD", err)
}
Expand Down
15 changes: 13 additions & 2 deletions tools/cli/internal/cli/changelog/metadata/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ func TestCreateBuild_Run(t *testing.T) {
opts := &Opts{
specRevision: "11110c256dffdb163be71a3ca70854a57fad5f6f",
runDate: "2024-01-01",
versions: []string{"2024-01-01"},
versions: []string{"2024-01-01", "2024-01-01.upcoming"},
fs: fs,
}

require.NoError(t, opts.Run())
}

Expand All @@ -47,6 +46,18 @@ func TestCreateBuild_PreRun_InvalidVersion(t *testing.T) {
require.ErrorContains(t, opts.PreRun(), "invalid version date")
}

func TestCreateBuild_PreRun_upcomingAPI(t *testing.T) {
fs := afero.NewMemMapFs()
opts := &Opts{
specRevision: "test",
runDate: "2024-01-01",
versions: []string{"2024-01-01", "2024-01-01.upcoming"},
fs: fs,
}

require.NoError(t, opts.PreRun())
}

func TestCreateBuilder(t *testing.T) {
test.CmdValidator(
t,
Expand Down
Loading