Skip to content
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

Remaining v2 changes #420

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions internal/document/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,6 @@ func (p *failoverAttributeParser) Write(attr Attributes, w io.Writer) error {
}

var DefaultDocumentParser = newFailoverAttributeParser(
[]attributeParser{
&babikMLParser{},
},
&babikMLParser{},
)

// todo(sebastian): make default in v2
var FutureDocumentParser = newFailoverAttributeParser(
[]attributeParser{
&jsonParser{},
&babikMLParser{},
Expand Down
2 changes: 1 addition & 1 deletion internal/document/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func Test_attributes(t *testing.T) {
})

t.Run("failoverAttributesParser", func(t *testing.T) {
parser := FutureDocumentParser
parser := DefaultDocumentParser

// parser handles json
{
Expand Down
24 changes: 9 additions & 15 deletions internal/document/editor/cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ echo 1
}

func Test_toCells_UnsupportedLang(t *testing.T) {
// todo(sebastian): make default in v2
document.DefaultDocumentParser = document.FutureDocumentParser
data := []byte("```py {\"readonly\":\"true\"}" + `
def hello():
print("Hello World")
Expand Down Expand Up @@ -326,8 +324,6 @@ pre-commit install
}

func Test_serializeCells(t *testing.T) {
// todo(sebastian): remove for v2
document.DefaultDocumentParser = document.FutureDocumentParser
t.Run("attributes_babikml", func(t *testing.T) {
data := []byte("```sh { name=echo first= second=2 }\necho 1\n```\n")
expected := []byte("```sh {\"first\":\"\",\"name\":\"echo\",\"second\":\"2\"}\necho 1\n```\n")
Expand Down Expand Up @@ -360,26 +356,24 @@ func Test_serializeCells(t *testing.T) {

assert.Equal(t, string(data), string(serializeCells(cells)))
})
}

t.Run("UnsupportedLang", func(t *testing.T) {
data := []byte(`## Non-Supported Languages
func Test_serializeCells_UnsupportedLang(t *testing.T) {
data := []byte(`## Non-Supported Languages

` + "```py {\"readonly\":\"true\"}" + `
def hello():
print("Hello World")
print("Hello World")
` + "```" + `
`)
doc := document.New(data, cmark.Render, identityResolverAll)
node, _, err := doc.Parse()
require.NoError(t, err)
cells := toCells(node, data)
assert.Equal(t, string(data), string(serializeCells(cells)))
})
doc := document.New(data, cmark.Render, identityResolverAll)
node, _, err := doc.Parse()
require.NoError(t, err)
cells := toCells(node, data)
assert.Equal(t, string(data), string(serializeCells(cells)))
}

func Test_serializeFencedCodeAttributes(t *testing.T) {
// todo(sebastian): remove for v2
document.DefaultDocumentParser = document.FutureDocumentParser
t.Run("NoMetadata", func(t *testing.T) {
var buf bytes.Buffer
serializeFencedCodeAttributes(&buf, &Cell{
Expand Down
18 changes: 9 additions & 9 deletions internal/document/editor/editorservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func Test_IdentityUnspecified(t *testing.T) {
assert.NotRegexp(t, "^\n\n", content)
}

assert.Contains(t, content, "```sh { name=foo id=123 }\n")
assert.Contains(t, content, "```sh {\"id\":\"123\",\"name\":\"foo\"}\n")
}
}

Expand Down Expand Up @@ -152,9 +152,9 @@ func Test_IdentityAll(t *testing.T) {
assert.Contains(t, content, "runme:\n")
assert.Contains(t, content, "id: "+testMockID)
assert.Contains(t, content, "version: "+version.BaseVersion())
assert.Contains(t, content, "```sh { name=foo id="+testMockID+" }\n")
assert.Contains(t, content, "```sh { name=bar id="+testMockID+" }\n")
assert.Contains(t, content, "```js { id="+testMockID+" }\n")
assert.Contains(t, content, "```sh {\"id\":\""+testMockID+"\",\"name\":\"foo\"}\n")
assert.Contains(t, content, "```sh {\"id\":\""+testMockID+"\",\"name\":\"bar\"}\n")
assert.Contains(t, content, "```js {\"id\":\""+testMockID+"\"}\n")
}
}

Expand Down Expand Up @@ -193,8 +193,8 @@ func Test_IdentityDocument(t *testing.T) {
assert.Contains(t, content, "runme:\n")
assert.Contains(t, content, "id: "+testMockID+"\n")
assert.Contains(t, content, "version: "+version.BaseVersion()+"\n")
assert.Contains(t, content, "```sh { name=foo id=123 }\n")
assert.Contains(t, content, "```sh { name=bar }\n")
assert.Contains(t, content, "```sh {\"id\":\"123\",\"name\":\"foo\"}\n")
assert.Contains(t, content, "```sh {\"name\":\"bar\"}\n")
assert.Contains(t, content, "```js\n")
}
}
Expand Down Expand Up @@ -241,9 +241,9 @@ func Test_IdentityCell(t *testing.T) {
assert.NotRegexp(t, "^\n\n", content)
}

assert.Contains(t, content, "```sh { name=foo id="+testMockID+" }\n")
assert.Contains(t, content, "```sh { name=bar id="+testMockID+" }\n")
assert.Contains(t, content, "```js { id="+testMockID+" }\n")
assert.Contains(t, content, "```sh {\"id\":\""+testMockID+"\",\"name\":\"foo\"}\n")
assert.Contains(t, content, "```sh {\"id\":\""+testMockID+"\",\"name\":\"bar\"}\n")
assert.Contains(t, content, "```js {\"id\":\""+testMockID+"\"}\n")
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/document/identity/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
type LifecycleIdentities []LifecycleIdentity

const (
DefaultLifecycleIdentity = UnspecifiedLifecycleIdentity
DefaultLifecycleIdentity = AllLifecycleIdentity
)

var documentIdentities = &LifecycleIdentities{
Expand Down
Loading