-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix package description template not having context (#96)
- Loading branch information
Showing
6 changed files
with
79 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ package server | |
import ( | ||
"net/url" | ||
"testing" | ||
|
||
"github.com/RiskIdent/jelease/pkg/config" | ||
) | ||
|
||
func TestCreateDeferredCreationURL(t *testing.T) { | ||
|
@@ -122,3 +124,55 @@ func TestCreateDeferredCreationURL(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestSetTemplateContextPackageDescription(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
ctx config.TemplateContext | ||
desc *config.Template | ||
want string | ||
}{ | ||
{ | ||
name: "empty", | ||
ctx: config.TemplateContext{}, | ||
desc: nil, | ||
want: "", | ||
}, | ||
{ | ||
name: "only package name", | ||
ctx: config.TemplateContext{Package: "my-pkg"}, | ||
desc: nil, | ||
want: "", | ||
}, | ||
{ | ||
name: "only package desc", | ||
ctx: config.TemplateContext{}, | ||
desc: config.MustTemplate("Pkg `{{.Package}}` desc"), | ||
want: "Pkg `` desc", | ||
}, | ||
{ | ||
name: "package name and desc", | ||
ctx: config.TemplateContext{Package: "my-pkg"}, | ||
desc: config.MustTemplate("Pkg `{{.Package}}` desc"), | ||
want: "Pkg `my-pkg` desc", | ||
}, | ||
{ | ||
name: "package name, version, and desc", | ||
ctx: config.TemplateContext{Package: "my-pkg", Version: "v1.2.3"}, | ||
desc: config.MustTemplate("Pkg `{{.Package}}@{{.Version}}` desc"), | ||
want: "Pkg `[email protected]` desc", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
got, err := setTemplateContextPackageDescription(test.ctx, test.desc) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if got.PackageDescription != test.want { | ||
t.Errorf("wrong result\nwant: %#v\ngot: %#v", test.want, got.PackageDescription) | ||
} | ||
}) | ||
} | ||
} |