Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jerbob92 committed Jun 28, 2023
1 parent 1ef2e12 commit 79c9969
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions shared_tests/fpdf_save.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var _ = Describe("fpdf_save", func() {
Expect(err).To(BeNil())
Expect(FPDF_SaveAsCopy).To(Not(BeNil()))
Expect(FPDF_SaveAsCopy.FileBytes).To(Not(BeNil()))
Expect(FPDF_SaveAsCopy.FileBytes).To(PointTo(HaveLen(11375)))
Expect(FPDF_SaveAsCopy.FileBytes).To(SatisfyAny(PointTo(HaveLen(11375)), PointTo(HaveLen(11183)))) // 11375 < Pdfium 5854, 11183 >= Pdfium 5854
})
})

Expand All @@ -93,7 +93,7 @@ var _ = Describe("fpdf_save", func() {
Expect(err).To(BeNil())
Expect(FPDF_SaveAsCopy).To(Not(BeNil()))
Expect(FPDF_SaveAsCopy.FileBytes).To(BeNil())
Expect(fileStat.Size()).To(Equal(int64(11375)))
Expect(fileStat.Size()).To(SatisfyAny(Equal(int64(11375)), Equal(int64(11183)))) // 11375 < Pdfium 5854, 11183 >= Pdfium 5854
})
})

Expand Down Expand Up @@ -126,7 +126,7 @@ var _ = Describe("fpdf_save", func() {
Expect(err).To(BeNil())
Expect(FPDF_SaveAsCopy).To(Not(BeNil()))
Expect(FPDF_SaveAsCopy.FileBytes).To(BeNil())
Expect(buffer.Len()).To(Equal(11375))
Expect(buffer.Len()).To(SatisfyAny(Equal(11375), Equal(11183))) // 11375 < Pdfium 5854, 11183 >= Pdfium 5854
})
})

Expand All @@ -139,7 +139,7 @@ var _ = Describe("fpdf_save", func() {
Expect(err).To(BeNil())
Expect(FPDF_SaveWithVersion).To(Not(BeNil()))
Expect(FPDF_SaveWithVersion.FileBytes).To(Not(BeNil()))
Expect(FPDF_SaveWithVersion.FileBytes).To(PointTo(HaveLen(11375)))
Expect(FPDF_SaveWithVersion.FileBytes).To(SatisfyAny(PointTo(HaveLen(11375)), PointTo(HaveLen(11183)))) // 11375 < Pdfium 5854, 11183 >= Pdfium 5854

savedDoc, err := PdfiumInstance.FPDF_LoadMemDocument(&requests.FPDF_LoadMemDocument{
Data: FPDF_SaveWithVersion.FileBytes,
Expand Down
14 changes: 14 additions & 0 deletions shared_tests/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,20 @@ func compareRenderHash(renderedPage *responses.RenderPage, expectedPage *respons

hasher.Write(buf.Bytes())
currentHash := fmt.Sprintf("%x", hasher.Sum(nil))

// Overwrite hash because Pdfium 5854 renders things a littlebit different,
// causing the hash to have changed.

// Webassembly
if currentHash == "81c72474d4d2dbba72d23257716983ff46005b2d1eba54b6ba88642c0512282a" {
currentHash = "3abd50c3c34f37fdc3941c22ff118e82974df8621551e2b821649b05120b5c83"
}

// CGO
if currentHash == "13ab9fbbcf144199cdbf15a4b4fa01a0b78e52fe97b68b533ac5ef02696aeda5" {
currentHash = "5162bbc4c340ed3204fc348a4a8fe4454812419dbde77f506dd87d7a3f39b721"
}

Expect(string(existingFileHash)).To(Equal(currentHash))
}

Expand Down

0 comments on commit 79c9969

Please sign in to comment.