@@ -17,6 +17,7 @@ func TestNodeJSDetector_Relevance(t *testing.T) {
1717 fs fstest.MapFS
1818 expected float64
1919 expectedPackages []string
20+ expectedEnv map [string ]string
2021 }{
2122 {
2223 name : "package.json in root" ,
@@ -27,6 +28,7 @@ func TestNodeJSDetector_Relevance(t *testing.T) {
2728 },
2829 expected : 1 ,
2930 expectedPackages : []string {"nodejs@latest" },
31+ expectedEnv : map [string ]string {"DEVBOX_COREPACK_ENABLED" : "1" },
3032 },
3133 {
3234 name : "package.json with node version" ,
@@ -41,6 +43,7 @@ func TestNodeJSDetector_Relevance(t *testing.T) {
4143 },
4244 expected : 1 ,
4345 expectedPackages : []
string {
"[email protected] " },
46+ expectedEnv : map [string ]string {"DEVBOX_COREPACK_ENABLED" : "1" },
4447 },
4548 {
4649 name : "no nodejs files" ,
@@ -54,12 +57,14 @@ func TestNodeJSDetector_Relevance(t *testing.T) {
5457 },
5558 expected : 0 ,
5659 expectedPackages : []string {},
60+ expectedEnv : map [string ]string {},
5761 },
5862 {
5963 name : "empty directory" ,
6064 fs : fstest.MapFS {},
6165 expected : 0 ,
6266 expectedPackages : []string {},
67+ expectedEnv : map [string ]string {},
6368 },
6469 }
6570
@@ -74,17 +79,21 @@ func TestNodeJSDetector_Relevance(t *testing.T) {
7479 require .NoError (t , err )
7580 }
7681
77- d := & NodeJSDetector {Root : dir }
78- err := d .Init ()
82+ detector := & NodeJSDetector {Root : dir }
83+ err := detector .Init ()
7984 require .NoError (t , err )
8085
81- score , err := d .Relevance (dir )
86+ score , err := detector .Relevance (dir )
8287 require .NoError (t , err )
8388 assert .Equal (t , curTest .expected , score )
8489 if score > 0 {
85- packages , err := d .Packages (context .Background ())
90+ packages , err := detector .Packages (context .Background ())
8691 require .NoError (t , err )
8792 assert .Equal (t , curTest .expectedPackages , packages )
93+
94+ env , err := detector .Env (context .Background ())
95+ require .NoError (t , err )
96+ assert .Equal (t , curTest .expectedEnv , env )
8897 }
8998 })
9099 }
@@ -96,3 +105,10 @@ func TestNodeJSDetector_Packages(t *testing.T) {
96105 require .NoError (t , err )
97106 assert .Equal (t , []string {"nodejs@latest" }, packages )
98107}
108+
109+ func TestNodeJSDetector_Env (t * testing.T ) {
110+ d := & NodeJSDetector {}
111+ env , err := d .Env (context .Background ())
112+ require .NoError (t , err )
113+ assert .Equal (t , map [string ]string {"DEVBOX_COREPACK_ENABLED" : "1" }, env )
114+ }
0 commit comments