Skip to content

Commit

Permalink
Merge pull request #4 from chanti529/unit-tests
Browse files Browse the repository at this point in the history
Added unit tests
  • Loading branch information
chanti529 authored Apr 22, 2021
2 parents 2ba5b0b + 6dcecf0 commit 62dc74c
Show file tree
Hide file tree
Showing 12 changed files with 952 additions and 23 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ This command gives the info about the size of an Artifact/Folder/Repository in B
- max-depth: [Default: 4] Max depth to group folders when using folder command type
- Examples:
```
$ jfrog repostats download artifact -repos jcenter-remote -path .+.jar
$ jfrog repostats download artifact --repos jcenter-remote --path .+.jar
$ jfrog repostats downlaod folder -repos jcenter-remote -path .+.jar -lastdownloadedto 2020-05-12T15:55:00Z -limit 0 -max-depth 2
$ jfrog repostats downlaod folder --repos jcenter-remote --path .+.jar --lastdownloadedto 2020-05-12T15:55:00Z --limit 0 --max-depth 2
$ jfrog repostats download user -repos jcenter-remote -path .+.jar -lastdownloadedto 2020-05-12T15:55:00Z -limit 0
$ jfrog repostats download user --repos jcenter-remote --path .+.jar --lastdownloadedto 2020-05-12T15:55:00Z --limit 0
```

Expand All @@ -68,7 +68,7 @@ This command gives the info about the size of an Artifact/Folder/Repository in B
- max-depth: [Default: 4] Max depth to group folders when using folder command type
- Examples:
```
$ jfrog repostats size artifact -repos maven-local -path .+.jar
$ jfrog repostats size artifact --repos maven-local --path .+.jar
```

Expand Down
8 changes: 7 additions & 1 deletion commands/repostatdownload.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/chanti529/repostats/service"
"github.com/chanti529/repostats/util"
"github.com/cheynewallace/tabby"
"github.com/jfrog/jfrog-cli-core/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/plugins/components"
"strconv"
"text/tabwriter"
Expand Down Expand Up @@ -75,7 +76,12 @@ func repoStatDownloadCmd(c *components.Context) error {
}
conf.LastDownloadedTo = lastDownloadedTo

results, err := service.GetDownloadStat(&conf)
servicesManager, err := utils.CreateServiceManager(conf.RtDetails, false)
if err != nil {
return err
}

results, err := service.GetDownloadStat(&conf, servicesManager)
if err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion commands/repostatsize.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/chanti529/repostats/service"
"github.com/chanti529/repostats/util"
"github.com/cheynewallace/tabby"
"github.com/jfrog/jfrog-cli-core/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/plugins/components"
"strconv"
"text/tabwriter"
Expand Down Expand Up @@ -75,7 +76,12 @@ func repoStatSizeCmd(c *components.Context) error {
}
conf.ModifiedTo = modifiedTo

results, err := service.GetSizeStat(&conf)
servicesManager, err := utils.CreateServiceManager(conf.RtDetails, false)
if err != nil {
return err
}

results, err := service.GetSizeStat(&conf, servicesManager)
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion service/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func getItemIdentity(item *util.AqlItem, conf *RepoStatConfiguration) (string, e
} else {
return strings.Join(pathParts[:conf.MaxDepth], "/"), nil
}
return "", errors.New("Not implemented")
case TypeArtifact:
return item.GetFullPath(), nil
case TypeUser:
Expand Down
9 changes: 2 additions & 7 deletions service/repostatdownload.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/chanti529/repostats/util"
"github.com/jfrog/jfrog-cli-core/artifactory/utils"
"github.com/jfrog/jfrog-client-go/artifactory"
"io/ioutil"
)

Expand All @@ -13,12 +13,7 @@ const (
aqlDownloadTemplate = `items.find(%s).include("repo", "path", "name", "modified", "modified_by", "stat.downloads", "stat.downloaded")`
)

func GetDownloadStat(conf *RepoStatConfiguration) ([]StatItem, error) {
servicesManager, err := utils.CreateServiceManager(conf.RtDetails, false)
if err != nil {
return nil, err
}

func GetDownloadStat(conf *RepoStatConfiguration, servicesManager artifactory.ArtifactoryServicesManager) ([]StatItem, error) {
aqlCriteria := util.AqlSearchCriteria{
Repos: conf.Repos,
PropertyFilter: conf.FilterProperties,
Expand Down
Loading

0 comments on commit 62dc74c

Please sign in to comment.