diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 0000000..9c33b19 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,53 @@ +version: '3' + +services: + nexus: + image: docker.io/sonatype/nexus3 + ports: + - "8081:8081" + volumes: + - nexus-data:/nexus-data + deploy: + replicas: 1 + placement: + constraints: [node.role == manager] + resources: + limits: + cpus: "0.5" + memory: 2G + reservations: + cpus: "0.25" + memory: 1G + environment: + - NEXUS_CONTEXT_PATH=/nexus + - NEXUS_SECURITY_ANONYMOUS_ENABLED=true + - NEXUS_SECURITY_REALM=local + + gitea: + image: codeberg.org/forgejo/forgejo:9.0 + ports: + - "3000:3000" + volumes: + - gitea-data:/data + deploy: + replicas: 1 + placement: + constraints: [node.role == manager] + resources: + limits: + cpus: "0.5" + memory: 2G + reservations: + cpus: "0.25" + memory: 1G + environment: + - GITEA_ROOT_URL=http://gitea:3000 + - GITEA_DB_TYPE=sqlite3 + - GITEA_DB_PATH=/data/gitea.db + +volumes: + nexus-data: + driver: local + gitea-data: + driver: local + diff --git a/repository/gitea/gitea_mock.go b/repository/gitea/gitea_mock.go new file mode 100644 index 0000000..649f693 --- /dev/null +++ b/repository/gitea/gitea_mock.go @@ -0,0 +1,16 @@ +// gitea_mock.go + +package gitea + +import ( + "github.com/stretchr/testify/mock" +) + +type MockClient struct { + mock.Mock +} + +func (m *MockClient) ArtifactExists(owner, repo, artifact string) (bool, error) { + args := m.Called(owner, repo, artifact) + return args.Bool(0), args.Error(1) +} diff --git a/repository/nexus/nexus_mock.go b/repository/nexus/nexus_mock.go new file mode 100644 index 0000000..7028203 --- /dev/null +++ b/repository/nexus/nexus_mock.go @@ -0,0 +1,36 @@ +// nexus_mock.go +package nexus + +import ( + "net/http" + "net/http/httptest" + + "github.com/stretchr/testify/mock" +) + +type MockClient struct { + mock.Mock + Server *httptest.Server +} + +func NewMockClient() *MockClient { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Здесь мы можем определить логику для обработки запросов + w.WriteHeader(200) + w.Write([]byte("artifact1\nartifact2\n")) + })) + return &MockClient{ + Server: server, + } +} + +func (m *MockClient) GetArtifacts(repository string) ([]string, error) { + args := m.Called(repository) + return args.Get(0).([]string), args.Error(1) +} + +func (m *MockClient) GetArtifactData(repository, artifact string) ([]byte, error) { + args := m.Called(repository, artifact) + return args.Get(0).([]byte), args.Error(1) +} +