-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Closes #12 - Introducing fake client 🙈 Signed-off-by: Ricardo Zanini <[email protected]> * Add Maven Repository services fake Signed-off-by: Ricardo Zanini <[email protected]> * Fixing Maven proxy repo bug Signed-off-by: Ricardo Zanini <[email protected]> * Writing documentation Signed-off-by: Ricardo Zanini <[email protected]>
- Loading branch information
1 parent
e84c204
commit 7078f9e
Showing
13 changed files
with
344 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2020 Aicura Nexus Client and/or its authors | ||
// | ||
// This file is part of Aicura Nexus Client. | ||
// | ||
// Aicura Nexus Client is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Aicura Nexus Client is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with Aicura Nexus Client. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package nexus | ||
|
||
type mvnGroupFakeService struct{} | ||
|
||
var mvnGrpFake = make(map[string]*MavenGroupRepository) | ||
|
||
func (m *mvnGroupFakeService) Update(repo MavenGroupRepository) error { | ||
if mvnGrpFake[repo.Name] == nil { | ||
return nil | ||
} | ||
mvnGrpFake[repo.Name] = &repo | ||
return nil | ||
} | ||
|
||
func (m *mvnGroupFakeService) List() ([]MavenGroupRepository, error) { | ||
repos := make([]MavenGroupRepository, 0) | ||
for _, repo := range mvnGrpFake { | ||
repos = append(repos, *repo) | ||
} | ||
return repos, nil | ||
} | ||
|
||
func (m *mvnGroupFakeService) GetRepoByName(name string) (*MavenGroupRepository, error) { | ||
return mvnGrpFake[name], nil | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2020 Aicura Nexus Client and/or its authors | ||
// | ||
// This file is part of Aicura Nexus Client. | ||
// | ||
// Aicura Nexus Client is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Aicura Nexus Client is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with Aicura Nexus Client. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package nexus | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMvnGroupServiceFakeCheck(t *testing.T) { | ||
client := NewFakeClient() | ||
repos, err := client.MavenGroupRepositoryService.List() | ||
assert.NoError(t, err) | ||
assert.Empty(t, repos) | ||
group := MavenGroupRepository{ | ||
Repository: Repository{ | ||
Name: "maven-public", | ||
}, | ||
} | ||
err = client.MavenGroupRepositoryService.Update(group) | ||
assert.NoError(t, err) | ||
newGroup, err := client.MavenGroupRepositoryService.GetRepoByName("maven-public") | ||
assert.NoError(t, err) | ||
assert.Nil(t, newGroup) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2020 Aicura Nexus Client and/or its authors | ||
// | ||
// This file is part of Aicura Nexus Client. | ||
// | ||
// Aicura Nexus Client is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Aicura Nexus Client is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with Aicura Nexus Client. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package nexus | ||
|
||
type mvnProxyFakeService struct{} | ||
|
||
var mvnProxyFake = make(map[string]*MavenProxyRepository) | ||
|
||
func (m *mvnProxyFakeService) Add(repositories ...MavenProxyRepository) error { | ||
for _, repo := range repositories { | ||
mvnProxyFake[repo.Name] = &repo | ||
} | ||
return nil | ||
} | ||
|
||
func (m *mvnProxyFakeService) List() ([]MavenProxyRepository, error) { | ||
repos := make([]MavenProxyRepository, 0) | ||
for _, repo := range mvnProxyFake { | ||
repos = append(repos, *repo) | ||
} | ||
return repos, nil | ||
} | ||
|
||
func (m *mvnProxyFakeService) GetRepoByName(name string) (*MavenProxyRepository, error) { | ||
return mvnProxyFake[name], nil | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2020 Aicura Nexus Client and/or its authors | ||
// | ||
// This file is part of Aicura Nexus Client. | ||
// | ||
// Aicura Nexus Client is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Aicura Nexus Client is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with Aicura Nexus Client. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package nexus | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMvnProxyServiceFakeCheck(t *testing.T) { | ||
client := NewFakeClient() | ||
repo := apacheMavenRepoMockData | ||
err := client.MavenProxyRepositoryService.Add(repo) | ||
assert.NoError(t, err) | ||
newRepo, err := client.MavenProxyRepositoryService.GetRepoByName(repo.Name) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, newRepo) | ||
assert.Equal(t, "apache", newRepo.Name) | ||
repos, err := client.MavenProxyRepositoryService.List() | ||
assert.NoError(t, err) | ||
assert.Len(t, repos, 1) | ||
} |
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
Oops, something went wrong.