Skip to content

Commit

Permalink
Fix errors and cleanup dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwareus authored and ProgHaj committed Sep 18, 2023
1 parent b4914f7 commit ee6612b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 54 deletions.
20 changes: 1 addition & 19 deletions build/docker/alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,4 @@ ENV GRADLE_HOME /usr/lib/gradle
ENV PATH $GRADLE_HOME/gradle-$GRADLE_VERSION/bin:$PATH
RUN wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip && \
unzip gradle-$GRADLE_VERSION-bin.zip -d $GRADLE_HOME && \
rm gradle-$GRADLE_VERSION-bin.zip


# ENV BIN_DIRECTORY /usr/bin
# ENV DOTNET_DIRECTORY /usr/bin/dotnet

# #Install dotnet
# RUN apk add --no-cache --virtual build-dependencies curl \
# && curl -SL --output dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/f8834fef-d2ab-4cf6-abc3-d8d79cfcde11/0ee05ef4af5fe324ce2977021bf9f340/dotnet-sdk-3.1.426-linux-musl-x64.tar.gz \
# && mkdir -p $DOTNET_DIRECTORY \
# && tar zxf dotnet.tar.gz -C $DOTNET_DIRECTORY \
# && chmod +x $DOTNET_DIRECTORY/dotnet \
# && rm dotnet.tar.gz \
# && apk del build-dependencies \
# && rm -r $DOTNET_DIRECTORY/packs $DOTNET_DIRECTORY/sdk/3.1.426/TestHost $DOTNET_DIRECTORY/sdk/3.1.426/Extensions \
# $DOTNET_DIRECTORY/sdk/3.1.426/FSharp $DOTNET_DIRECTORY/sdk/3.1.426/Roslyn



rm gradle-$GRADLE_VERSION-bin.zip
1 change: 1 addition & 0 deletions internal/file/default_exclusion.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ func DefaultExclusions() []string {
filepath.Join("**", "node_modules", "**"),
filepath.Join("**", "vendor", "**"),
filepath.Join("**", ".git", "**"),
filepath.Join("**", "obj", "**"), // nuget
}
}
1 change: 1 addition & 0 deletions internal/resolution/pm/nuget/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (j *Job) Run() {
} else {
j.Errors().Critical(errors.New(string(output)))
}

return
}
}
Expand Down
19 changes: 0 additions & 19 deletions internal/resolution/pm/nuget/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,3 @@ func TestRunInstallCmdOutputErr(t *testing.T) {

jobTestdata.AssertPathErr(t, j.Errors())
}

func TestRunInstallCmdOutputAndErr(t *testing.T) {
// Setup mock to return a specific error and output
expectedError := errors.New("expected error")
expectedOutput := []byte("expected output")

cmdFactoryMock := testdata.NewEchoCmdFactory()
cmdFactoryMock.CmdOutput = expectedOutput
cmdFactoryMock.CmdError = expectedError

j := NewJob("file", true, cmdFactoryMock)

go jobTestdata.WaitStatus(j)
j.Run()

// Check that the error recorded in j.Errors() matches the error created from the output
assert.Len(t, j.Errors().GetAll(), 1)
assert.Contains(t, j.Errors().GetAll(), errors.New(string(expectedOutput)))
}
18 changes: 2 additions & 16 deletions internal/resolution/pm/nuget/testdata/cmd_factory_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,14 @@ import (
type CmdFactoryMock struct {
InstallCmdName string
MakeInstallErr error
CmdOutput []byte
CmdError error
}

func NewEchoCmdFactory() CmdFactoryMock {
return CmdFactoryMock{
InstallCmdName: "echo",
}
}
func (f CmdFactoryMock) MakeInstallCmd(command string, file string) (*exec.Cmd, error) {
if f.MakeInstallErr != nil {
return nil, f.MakeInstallErr
}

cmd := exec.Command(f.InstallCmdName)
if f.CmdError != nil {
cmd = exec.Command("sh", "-c", f.InstallCmdName+" && exit 1")
}

if f.CmdOutput != nil {
cmd = exec.Command("sh", "-c", "echo -n \""+string(f.CmdOutput)+"\" && exit 1")
}

return cmd, nil
func (f CmdFactoryMock) MakeInstallCmd(command string, file string) (*exec.Cmd, error) {
return exec.Command(f.InstallCmdName), f.MakeInstallErr
}

0 comments on commit ee6612b

Please sign in to comment.