Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
primitives
Manage
Activity
Members
Labels
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xx network
primitives
Commits
97747936
Commit
97747936
authored
Mar 7, 2023
by
Richard T. Carback III
Browse files
Options
Downloads
Plain Diff
Merge branch 'XX-4464/RemoteStorage' into 'release'
Xx 4464/remote storage See merge request
!42
parents
81c2cb07
7a76f11e
No related branches found
No related tags found
2 merge requests
!42
Xx 4464/remote storage
,
!34
Release
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
utils/utils.go
+18
-0
18 additions, 0 deletions
utils/utils.go
utils/utils_test.go
+14
-0
14 additions, 0 deletions
utils/utils_test.go
with
32 additions
and
0 deletions
utils/utils.go
+
18
−
0
View file @
97747936
...
...
@@ -165,6 +165,24 @@ func GetLastModified(path string) (time.Time, error) {
return
info
.
ModTime
(),
nil
}
// ReadDir reads the named directory, returning all its directory entries
// sorted by filename.
func
ReadDir
(
path
string
)
([]
string
,
error
)
{
entries
,
err
:=
os
.
ReadDir
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
files
:=
make
([]
string
,
0
)
for
_
,
entry
:=
range
entries
{
if
!
entry
.
IsDir
()
{
files
=
append
(
files
,
entry
.
Name
())
}
}
return
files
,
nil
}
// exists checks if a file or directory exists at the specified path and also
// returns the file's FileInfo.
func
exists
(
path
string
)
(
os
.
FileInfo
,
bool
)
{
...
...
This diff is collapsed.
Click to expand it.
utils/utils_test.go
+
14
−
0
View file @
97747936
...
...
@@ -553,6 +553,20 @@ func TestGetLastModified(t *testing.T) {
require
.
Equal
(
t
,
newLastModified
,
lastModified
)
}
// ReadDir unit test.
func
TestReadDir
(
t
*
testing
.
T
)
{
files
,
err
:=
ReadDir
(
"./"
)
require
.
NoError
(
t
,
err
)
// NOTE: This test uses the files in the utils package as expected values.
// If at any point files are added or moved, refactor this list
// accordingly.
var
expectedFiles
=
[]
string
{
"gen.go"
,
"net.go"
,
"net_test.go"
,
"privNet.go"
,
"utils.go"
,
"utils_test.go"
}
require
.
Equal
(
t
,
expectedFiles
,
files
)
}
// Tests that GetLastModified will update after a write operation to a file.
func
TestGetLastModified_Update
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment