-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unescape Value-Type: TEXT in Golang Model #91
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
008589d
add: stable serialization of property parameters
brenank baa1c1d
add: serialiation test
brenank ea37e62
fix: VFREEBUSY serialization
brenank 8d1cec9
breaking: unescape Property.Value of type TEXT
brenank 68b453c
refactor: fix linting errors
brenank b866620
refactor: reduce scope of gitignore
brenank 2f726f2
refactor: switch syntax
brenank 9a99514
fix: add test err assertion
brenank 20061ba
fix: reduce build restriction on serialization test
brenank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/.idea/ | ||
actual | ||
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,77 @@ | ||
//go:build go1.18 | ||
arran4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// +build go1.18 | ||
|
||
package ics | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCalendar_ReSerialization(t *testing.T) { | ||
testDir := "testdata/serialization" | ||
expectedDir := filepath.Join(testDir, "expected") | ||
actualDir := filepath.Join(testDir, "actual") | ||
|
||
testFileNames := []string{ | ||
"input1.ics", | ||
"input2.ics", | ||
"input3.ics", | ||
"input4.ics", | ||
"input5.ics", | ||
"input6.ics", | ||
"input7.ics", | ||
} | ||
|
||
for _, filename := range testFileNames { | ||
t.Run(fmt.Sprintf("compare serialized -> deserialized -> serialized: %s", filename), func(t *testing.T) { | ||
//given | ||
originalSeriailizedCal, err := os.ReadFile(filepath.Join(testDir, filename)) | ||
require.NoError(t, err) | ||
|
||
//when | ||
deserializedCal, err := ParseCalendar(bytes.NewReader(originalSeriailizedCal)) | ||
require.NoError(t, err) | ||
serializedCal := deserializedCal.Serialize() | ||
|
||
//then | ||
expectedCal, _ := os.ReadFile(filepath.Join(expectedDir, filename)) | ||
arran4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if diff := cmp.Diff(string(expectedCal), serializedCal); diff != "" { | ||
err = os.MkdirAll(actualDir, 0755) | ||
if err != nil { | ||
t.Logf("failed to create actual dir: %v", err) | ||
} | ||
err = os.WriteFile(filepath.Join(actualDir, filename), []byte(serializedCal), 0644) | ||
if err != nil { | ||
t.Logf("failed to write actual file: %v", err) | ||
} | ||
t.Error(diff) | ||
} | ||
}) | ||
|
||
t.Run(fmt.Sprintf("compare deserialized -> serialized -> deserialized: %s", filename), func(t *testing.T) { | ||
//given | ||
loadIcsContent, err := os.ReadFile(filepath.Join(testDir, filename)) | ||
require.NoError(t, err) | ||
originalDeserializedCal, err := ParseCalendar(bytes.NewReader(loadIcsContent)) | ||
require.NoError(t, err) | ||
|
||
//when | ||
serializedCal := originalDeserializedCal.Serialize() | ||
deserializedCal, err := ParseCalendar(strings.NewReader(serializedCal)) | ||
require.NoError(t, err) | ||
|
||
//then | ||
if diff := cmp.Diff(originalDeserializedCal, deserializedCal); diff != "" { | ||
t.Error(diff) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind extra entries but this one seems like it's your side only, perhaps add it to your
$PROJECT/.git/info/exclude
list rather than$PROJECT/.gitignore
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test outputs this folder if it fails for easy comparison and updating of the expected values. It should never be checked in so I figured it should be added to project level gitignore.
I can scope it down to be more specific if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no issue with the line being there, however it should be
so that it isn't applied throughout the entire directory structure. Just we aren't generating any runtime data for
actual
as far as I can tell so it might have been better in the.git/info/exclude
file (which is per repo and local only.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scoped this more narrowly, since this does create files during runtime (only when running serialization test & only if there are failures)