Repository: dragonflyoss/Dragonfly2
Pull request #913 (2021-12-09 13:03:51)

test: idgen peer id
Signed-off-by: Gaius <gaius.qi@gmail.com>

<!--- Provide a general summary of your changes in the Title above -->

## Description
- Fix idgen peer id test.
<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation Update (if none of the other choices apply)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] Code compiles correctly.
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.



Patch:
diff --git a/docs/en/deployment/configuration/dfget.yaml b/docs/en/deployment/configuration/dfget.yaml
index fb1c1b4b..9ef46a99 100644
--- a/docs/en/deployment/configuration/dfget.yaml
+++ b/docs/en/deployment/configuration/dfget.yaml
@@ -21,7 +21,7 @@ cacheDir: ""
 logDir: ""
 
 # dataDir is the download data storage directory
-# in linux, default value is /var/bin/dragonfly
+# in linux, default value is /var/lib/dragonfly
 # in macos(just for testing), default value is /Users/$USER/.dragonfly/data
 dataDir: ""
 


Test patch:
diff --git a/internal/idgen/peer_id_test.go b/internal/idgen/peer_id_test.go
index 6ba937b3..3ec85347 100644
--- a/internal/idgen/peer_id_test.go
+++ b/internal/idgen/peer_id_test.go
@@ -33,7 +33,7 @@ func TestPeerID(t *testing.T) {
 			ip:   "127.0.0.1",
 			expect: func(t *testing.T, d interface{}) {
 				assert := assert.New(t)
-				assert.Len(d, 52)
+				assert.Regexp("127.0.0.1-.*-.*", d)
 			},
 		},
 		{
@@ -41,7 +41,7 @@ func TestPeerID(t *testing.T) {
 			ip:   "2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b",
 			expect: func(t *testing.T, d interface{}) {
 				assert := assert.New(t)
-				assert.Len(d, 82)
+				assert.Regexp("2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b-.*-.*", d)
 			},
 		},
 		{
@@ -49,7 +49,7 @@ func TestPeerID(t *testing.T) {
 			ip:   "",
 			expect: func(t *testing.T, d interface{}) {
 				assert := assert.New(t)
-				assert.Len(d, 43)
+				assert.Regexp("-.*-.*", d)
 			},
 		},
 	}
@@ -73,7 +73,7 @@ func TestCDNPeerID(t *testing.T) {
 			ip:   "127.0.0.1",
 			expect: func(t *testing.T, d interface{}) {
 				assert := assert.New(t)
-				assert.Len(d, 56)
+				assert.Regexp("127.0.0.1-.*-.*_CDN", d)
 			},
 		},
 		{
@@ -81,7 +81,7 @@ func TestCDNPeerID(t *testing.T) {
 			ip:   "2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b",
 			expect: func(t *testing.T, d interface{}) {
 				assert := assert.New(t)
-				assert.Len(d, 86)
+				assert.Regexp("2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b-.*-.*_CDN", d)
 			},
 		},
 		{
@@ -89,7 +89,7 @@ func TestCDNPeerID(t *testing.T) {
 			ip:   "",
 			expect: func(t *testing.T, d interface{}) {
 				assert := assert.New(t)
-				assert.Len(d, 47)
+				assert.Regexp("-.*-.*_CDN", d)
 			},
 		},
 	}