From 14867708cb446ef99a8797653222f3ffc4d8e9f7 Mon Sep 17 00:00:00 2001 From: Salman Shah Date: Sat, 2 Mar 2024 16:58:47 +0000 Subject: [PATCH 1/5] "Enhancements to Blog Post Verification" - Added a check for the presence of the truncate string in blog post files - Created unit tests for the new truncate string verification --- tools/checkdocs/checkdocs.go | 14 ++++++++++++++ tools/checkdocs/checkdocs_test.go | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tools/checkdocs/checkdocs.go b/tools/checkdocs/checkdocs.go index e09c052dcfe0..0989ff4bd422 100644 --- a/tools/checkdocs/checkdocs.go +++ b/tools/checkdocs/checkdocs.go @@ -68,6 +68,12 @@ func checkFiles(files []string, logf, fatalf func(string, ...any)) { logf("%q: %s", file, err) failed = true } + + // Check for the truncate string + if err = verifyTruncateString(b); err != nil { + logf("%q: %s", file, err) + failed = true + } } if failed { @@ -75,6 +81,14 @@ func checkFiles(files []string, logf, fatalf func(string, ...any)) { } } +// verifyTruncateString checks that the truncate string is present. +func verifyTruncateString(b []byte) error { + if !bytes.Contains(b, []byte("")) { + return fmt.Errorf("truncate string not found") + } + return nil +} + // extractFrontMatter returns the front matter of a blog post. func extractFrontMatter(fm []byte) ([]byte, error) { var in bool diff --git a/tools/checkdocs/checkdocs_test.go b/tools/checkdocs/checkdocs_test.go index 0e5d8fcf23e7..a271eb9456b9 100644 --- a/tools/checkdocs/checkdocs_test.go +++ b/tools/checkdocs/checkdocs_test.go @@ -62,3 +62,15 @@ func TestVerifyTags(t *testing.T) { err := verifyTags(fm) assert.EqualError(t, err, `tag "documents databases" is not in the allowed list`) } + +func TestVerifyTruncateString(t *testing.T) { + // Test case where truncate string is present + b := []byte("This is a blog post. The rest of the post...") + err := verifyTruncateString(b) + assert.NoError(t, err) + + // Test case where truncate string is not present + b = []byte("This is a blog post without a truncate string.") + err = verifyTruncateString(b) + assert.EqualError(t, err, "truncate string not found") +} \ No newline at end of file From ae511efe2915e889895afdc6c7fb58ab26df3bbe Mon Sep 17 00:00:00 2001 From: sbshah97 Date: Wed, 6 Mar 2024 23:18:05 +0000 Subject: [PATCH 2/5] Updated to run linter and fmt along with updated error message --- tools/checkdocs/checkdocs.go | 9 +++++---- tools/checkdocs/checkdocs_test.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/checkdocs/checkdocs.go b/tools/checkdocs/checkdocs.go index 0989ff4bd422..e805039c5871 100644 --- a/tools/checkdocs/checkdocs.go +++ b/tools/checkdocs/checkdocs.go @@ -83,10 +83,11 @@ func checkFiles(files []string, logf, fatalf func(string, ...any)) { // verifyTruncateString checks that the truncate string is present. func verifyTruncateString(b []byte) error { - if !bytes.Contains(b, []byte("")) { - return fmt.Errorf("truncate string not found") - } - return nil + if !bytes.Contains(b, []byte("")) { + return fmt.Errorf(" must be included to have \"Read more\" link on the homepage") + } + + return nil } // extractFrontMatter returns the front matter of a blog post. diff --git a/tools/checkdocs/checkdocs_test.go b/tools/checkdocs/checkdocs_test.go index a271eb9456b9..c11fefc5016d 100644 --- a/tools/checkdocs/checkdocs_test.go +++ b/tools/checkdocs/checkdocs_test.go @@ -72,5 +72,5 @@ func TestVerifyTruncateString(t *testing.T) { // Test case where truncate string is not present b = []byte("This is a blog post without a truncate string.") err = verifyTruncateString(b) - assert.EqualError(t, err, "truncate string not found") -} \ No newline at end of file + assert.EqualError(t, err, " must be included to have \"Read more\" link on the homepage") +} From c249cfc6de5f8118fe2bef7b6c58d1336ebcde20 Mon Sep 17 00:00:00 2001 From: sbshah97 Date: Thu, 7 Mar 2024 01:23:26 +0000 Subject: [PATCH 3/5] Fixed testcases along with renamed variables added truncate to missing file --- tools/checkdocs/checkdocs.go | 7 ++++--- tools/checkdocs/checkdocs_test.go | 8 +------- ...01-08-new-ferretdb-v118-support-oplog-functionality.md | 2 ++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tools/checkdocs/checkdocs.go b/tools/checkdocs/checkdocs.go index e805039c5871..ae42ff5b7d11 100644 --- a/tools/checkdocs/checkdocs.go +++ b/tools/checkdocs/checkdocs.go @@ -45,12 +45,13 @@ func checkFiles(files []string, logf, fatalf func(string, ...any)) { var failed bool for _, file := range files { - b, err := os.ReadFile(file) + fileInBytes, err := os.ReadFile(file) if err != nil { fatalf("Couldn't read file %s: %s", file, err) } - if b, err = extractFrontMatter(b); err != nil { + b, err := extractFrontMatter(fileInBytes) + if err != nil { fatalf("Couldn't extract front matter from %s: %s", file, err) } @@ -70,7 +71,7 @@ func checkFiles(files []string, logf, fatalf func(string, ...any)) { } // Check for the truncate string - if err = verifyTruncateString(b); err != nil { + if err = verifyTruncateString(fileInBytes); err != nil { logf("%q: %s", file, err) failed = true } diff --git a/tools/checkdocs/checkdocs_test.go b/tools/checkdocs/checkdocs_test.go index c11fefc5016d..fa984c3ee1ec 100644 --- a/tools/checkdocs/checkdocs_test.go +++ b/tools/checkdocs/checkdocs_test.go @@ -64,13 +64,7 @@ func TestVerifyTags(t *testing.T) { } func TestVerifyTruncateString(t *testing.T) { - // Test case where truncate string is present - b := []byte("This is a blog post. The rest of the post...") - err := verifyTruncateString(b) - assert.NoError(t, err) - // Test case where truncate string is not present - b = []byte("This is a blog post without a truncate string.") - err = verifyTruncateString(b) + err := verifyTruncateString(fm) assert.EqualError(t, err, " must be included to have \"Read more\" link on the homepage") } diff --git a/website/blog/2024-01-08-new-ferretdb-v118-support-oplog-functionality.md b/website/blog/2024-01-08-new-ferretdb-v118-support-oplog-functionality.md index e5ed4859d786..7c0cf35a5de3 100644 --- a/website/blog/2024-01-08-new-ferretdb-v118-support-oplog-functionality.md +++ b/website/blog/2024-01-08-new-ferretdb-v118-support-oplog-functionality.md @@ -13,6 +13,8 @@ tags: [release] We are starting the new year with a major feature addition! The latest version of FerretDB v1.18.0 has just been released with support for basic OpLog functionality, along with other exciting features. + + OpLog (operations log) functionality has been one of our most requested features, and it would make it possible for developers to build real-time applications using the Meteor framework. We made this a priority in the last quarter and are super excited that it's now available. We can't wait to see what you build with FerretDB! From 29e7dcaf3c229404a04d90f3c5e44758ce243658 Mon Sep 17 00:00:00 2001 From: Chi Fujii Date: Thu, 7 Mar 2024 11:05:02 +0900 Subject: [PATCH 4/5] Update checkdocs.go --- tools/checkdocs/checkdocs.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/checkdocs/checkdocs.go b/tools/checkdocs/checkdocs.go index ae42ff5b7d11..200c0532abc0 100644 --- a/tools/checkdocs/checkdocs.go +++ b/tools/checkdocs/checkdocs.go @@ -70,7 +70,6 @@ func checkFiles(files []string, logf, fatalf func(string, ...any)) { failed = true } - // Check for the truncate string if err = verifyTruncateString(fileInBytes); err != nil { logf("%q: %s", file, err) failed = true From 8f7da1d30e4a21d1b369ae648b9b66b1db482f92 Mon Sep 17 00:00:00 2001 From: Chi Fujii Date: Thu, 7 Mar 2024 11:05:30 +0900 Subject: [PATCH 5/5] Update checkdocs_test.go --- tools/checkdocs/checkdocs_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/checkdocs/checkdocs_test.go b/tools/checkdocs/checkdocs_test.go index fa984c3ee1ec..274cfefd540a 100644 --- a/tools/checkdocs/checkdocs_test.go +++ b/tools/checkdocs/checkdocs_test.go @@ -64,7 +64,6 @@ func TestVerifyTags(t *testing.T) { } func TestVerifyTruncateString(t *testing.T) { - // Test case where truncate string is not present err := verifyTruncateString(fm) assert.EqualError(t, err, " must be included to have \"Read more\" link on the homepage") }