From ec07be593a0ada7481d541782666767f2180ccfc Mon Sep 17 00:00:00 2001
From: Manuel Mendez <mmendez534@gmail.com>
Date: Tue, 14 Dec 2021 13:12:54 -0500
Subject: [PATCH] Add test for export of GOROOT to env var

Signed-off-by: Manuel Mendez <mmendez534@gmail.com>
---
 __tests__/setup-go.test.ts | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts
index ba54900..6be0c03 100644
--- a/__tests__/setup-go.test.ts
+++ b/__tests__/setup-go.test.ts
@@ -49,6 +49,7 @@ describe('setup-go', () => {
     inSpy.mockImplementation(name => inputs[name]);
     getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
     getBooleanInputSpy.mockImplementation(name => inputs[name]);
+    exSpy = jest.spyOn(core, 'exportVariable');
 
     // node
     os = {};
@@ -230,6 +231,22 @@ describe('setup-go', () => {
     expect(logSpy).toHaveBeenCalledWith(`Setup go version spec 1.13.0`);
   });
 
+  it('exports GOROOT', async () => {
+    inputs['go-version'] = '1.13.0';
+    inSpy.mockImplementation(name => inputs[name]);
+
+    let toolPath = path.normalize('/cache/go/1.13.0/x64');
+    findSpy.mockImplementation(() => toolPath);
+
+    let vars = {} as any;
+    exSpy.mockImplementation(async (name, val) => {
+      vars[name] = val;
+    });
+
+    await main.run();
+    expect(vars).toBe({GOROOT: 'foo'});
+  });
+
   it('finds a version of go already in the cache', async () => {
     inputs['go-version'] = '1.13.0';