11package dotnetcoreaspnetruntime_test
22
33import (
4+ "bytes"
45 "os"
56 "testing"
67
78 dotnetcoreaspnetruntime "github.com/paketo-buildpacks/dotnet-core-aspnet-runtime"
89 "github.com/paketo-buildpacks/packit/v2"
10+ "github.com/paketo-buildpacks/packit/v2/scribe"
911 "github.com/sclevine/spec"
1012
1113 . "github.com/onsi/gomega"
@@ -17,14 +19,19 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
1719
1820 workingDir string
1921 detect packit.DetectFunc
22+ buffer * bytes.Buffer
2023 )
2124
2225 it .Before (func () {
2326 var err error
2427 workingDir , err = os .MkdirTemp ("" , "working-dir" )
2528 Expect (err ).NotTo (HaveOccurred ())
2629
27- detect = dotnetcoreaspnetruntime .Detect (dotnetcoreaspnetruntime.Environment {})
30+ buffer = bytes .NewBuffer (nil )
31+ detect = dotnetcoreaspnetruntime .Detect (
32+ dotnetcoreaspnetruntime.Environment {},
33+ scribe .NewEmitter (buffer ),
34+ )
2835 })
2936
3037 it .After (func () {
@@ -58,11 +65,59 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
5865 }))
5966 })
6067
61- context ("when BP_DOTNET_FRAMEWORK_VERSION is set" , func () {
68+ context ("when BP_DOTNET_RUNTIME_VERSION is set" , func () {
6269 it .Before (func () {
63- detect = dotnetcoreaspnetruntime .Detect (dotnetcoreaspnetruntime.Environment {
64- DotnetFrameworkVersion : "1.2.3" ,
70+ detect = dotnetcoreaspnetruntime .Detect (
71+ dotnetcoreaspnetruntime.Environment {
72+ DotnetRuntimeVersion : "1.2.3" ,
73+ },
74+ scribe .NewEmitter (buffer ))
75+ })
76+
77+ it ("provides and requires dotnet core runtime" , func () {
78+ result , err := detect (packit.DetectContext {
79+ WorkingDir : workingDir ,
6580 })
81+ Expect (err ).NotTo (HaveOccurred ())
82+ Expect (result .Plan ).To (Equal (packit.BuildPlan {
83+ Provides : []packit.BuildPlanProvision {
84+ {
85+ Name : "dotnet-core-aspnet-runtime" ,
86+ },
87+ },
88+ Requires : []packit.BuildPlanRequirement {
89+ {
90+ Name : "dotnet-core-aspnet-runtime" ,
91+ Metadata : map [string ]interface {}{
92+ "version-source" : "BP_DOTNET_RUNTIME_VERSION" ,
93+ "version" : "1.2.3" ,
94+ },
95+ },
96+ },
97+ Or : []packit.BuildPlan {
98+ {
99+ Provides : []packit.BuildPlanProvision {
100+ {Name : "dotnet-runtime" },
101+ },
102+ },
103+ {
104+ Provides : []packit.BuildPlanProvision {
105+ {Name : "dotnet-runtime" },
106+ {Name : "dotnet-aspnetcore" },
107+ },
108+ },
109+ },
110+ }))
111+ })
112+ })
113+
114+ context ("when BP_DOTNET_FRAMEWORK_VERSION is set" , func () {
115+ it .Before (func () {
116+ detect = dotnetcoreaspnetruntime .Detect (
117+ dotnetcoreaspnetruntime.Environment {
118+ DeprecatedDotnetFrameworkVersion : "1.2.3" ,
119+ },
120+ scribe .NewEmitter (buffer ))
66121 })
67122
68123 it ("provides and requires dotnet core runtime" , func () {
0 commit comments