Skip to content

Commit

Permalink
update to go 1.19 and node 18.x (getfider#1118)
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning authored Feb 6, 2023
1 parent 2e3f264 commit cce8efa
Show file tree
Hide file tree
Showing 35 changed files with 495 additions and 791 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
- run: npm ci
- run: make lint-ui
- run: make test-ui
Expand Down Expand Up @@ -49,17 +49,17 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Use Go 1.18
- name: Use Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Use Node.js 16.x
go-version: 1.19
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
- run: npm ci # required for esbuild
- name: install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.0
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.0
- name: install godotenv
run: go install github.com/joho/godotenv/cmd/godotenv
- run: make lint-server
Expand Down Expand Up @@ -124,10 +124,10 @@ jobs:
browser: ["chromium", "webkit", "firefox"]
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
- uses: actions/download-artifact@v2
with:
name: fider-image
Expand Down Expand Up @@ -178,10 +178,10 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
- uses: actions/download-artifact@v2
with:
name: fider-image
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.*
v18.*
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ If you know these technologies or would like to learn them, lucky you! This is t

| Software | How to install | What is it used for |
| ----------- | -------------------------------------------------------------- | --------------------------------------------------------- |
| Go 1.18+ | https://golang.org/ | To compile server side code |
| Node.js 16+ | https://nodejs.org/ or run `nvm use` if you have nvm installed | To compile TypeScript and bundle all the client side code |
| Go 1.19+ | https://golang.org/ | To compile server side code |
| Node.js 18+ | https://nodejs.org/ or run `nvm use` if you have nvm installed | To compile TypeScript and bundle all the client side code |
| Docker | https://www.docker.com/ | To start local PostgreSQL instances |

#### 2. To setup your development workspace:
Expand All @@ -31,7 +31,7 @@ If you know these technologies or would like to learn them, lucky you! This is t
2. navigate into the cloned repository.
3. run `go install github.com/cosmtrek/air` to install air, a cli tool for live reload, when you change the code, it automatically recompiles the application.
4. run `go install github.com/joho/godotenv/cmd/godotenv` to install godotenv, a cli tool to load environment variables from a `.env` so that you don't have to change your machine environment variables.
5. run `go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.0` to install golangci-lint, a linter for Go apps.
5. run `go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0` to install golangci-lint, a linter for Go apps.
6. run `npm install` to install client side packages.
7. run `docker-compose up -d` to start a local PostgreSQL database and Local SMTP (with [MailHog](https://github.com/mailhog/MailHog)) on Docker.
8. run `cp .example.env .env` to create a local environment configuration file.
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#####################
### Server Build Step
#####################
FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.18-buster AS server-builder
FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.19-bullseye AS server-builder


RUN mkdir /server
Expand All @@ -18,7 +18,7 @@ RUN COMMITHASH=${COMMITHASH} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-se
#################
### UI Build Step
#################
FROM --platform=${TARGETPLATFORM:-linux/amd64} node:16-buster AS ui-builder
FROM --platform=${TARGETPLATFORM:-linux/amd64} node:18-bullseye AS ui-builder

WORKDIR /ui

Expand All @@ -32,7 +32,7 @@ RUN make build-ui
################
### Runtime Step
################
FROM --platform=${TARGETPLATFORM:-linux/amd64} debian:buster-slim
FROM --platform=${TARGETPLATFORM:-linux/amd64} debian:bullseye-slim

RUN apt-get update
RUN apt-get install -y ca-certificates
Expand Down
4 changes: 2 additions & 2 deletions app/handlers/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package handlers_test
import (
"context"
"encoding/base64"
"io/ioutil"
"net/http"
"os"
"testing"

"github.com/getfider/fider/app/models/cmd"
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestUpdateSettingsHandler_NewLogo(t *testing.T) {
return nil
})

logoBytes, _ := ioutil.ReadFile(env.Etc("logo.png"))
logoBytes, _ := os.ReadFile(env.Etc("logo.png"))
logoB64 := base64.StdEncoding.EncodeToString(logoBytes)

server := mock.NewServer()
Expand Down
20 changes: 10 additions & 10 deletions app/handlers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package handlers

import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"time"

Expand All @@ -23,7 +23,7 @@ import (
"github.com/getfider/fider/app/pkg/web"
)

//Health always returns OK
// Health always returns OK
func Health() web.HandlerFunc {
return func(c *web.Context) error {
err := dbx.Ping()
Expand All @@ -34,10 +34,10 @@ func Health() web.HandlerFunc {
}
}

//LegalPage returns a legal page with content from a file
// LegalPage returns a legal page with content from a file
func LegalPage(title, file string) web.HandlerFunc {
return func(c *web.Context) error {
bytes, err := ioutil.ReadFile(env.Etc(file))
bytes, err := os.ReadFile(env.Etc(file))
if err != nil {
return c.NotFound()
}
Expand All @@ -52,7 +52,7 @@ func LegalPage(title, file string) web.HandlerFunc {
}
}

//Sitemap returns the sitemap.xml of current site
// Sitemap returns the sitemap.xml of current site
func Sitemap() web.HandlerFunc {
return func(c *web.Context) error {
if c.Tenant().IsPrivate {
Expand All @@ -79,10 +79,10 @@ func Sitemap() web.HandlerFunc {
}
}

//RobotsTXT return content of robots.txt file
// RobotsTXT return content of robots.txt file
func RobotsTXT() web.HandlerFunc {
return func(c *web.Context) error {
bytes, err := ioutil.ReadFile(env.Path("./robots.txt"))
bytes, err := os.ReadFile(env.Path("./robots.txt"))
if err != nil {
return c.NotFound()
}
Expand All @@ -92,7 +92,7 @@ func RobotsTXT() web.HandlerFunc {
}
}

//Page returns a page without properties
// Page returns a page without properties
func Page(title, description, page string) web.HandlerFunc {
return func(c *web.Context) error {
return c.Page(http.StatusOK, web.Props{
Expand All @@ -103,13 +103,13 @@ func Page(title, description, page string) web.HandlerFunc {
}
}

//NewLogError is the input model for UI errors
// NewLogError is the input model for UI errors
type NewLogError struct {
Message string `json:"message"`
Data any `json:"data"`
}

//LogError logs an error coming from the UI
// LogError logs an error coming from the UI
func LogError() web.HandlerFunc {
return func(c *web.Context) error {
action := new(NewLogError)
Expand Down
8 changes: 4 additions & 4 deletions app/handlers/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package handlers_test

import (
"context"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -62,7 +62,7 @@ func TestRobotsTXT(t *testing.T) {
code, response := server.
WithURL("https://demo.test.fider.io/robots.txt").
Execute(handlers.RobotsTXT())
content, _ := ioutil.ReadAll(response.Body)
content, _ := io.ReadAll(response.Body)
Expect(code).Equals(http.StatusOK)
Expect(string(content)).Equals(`User-agent: *
Disallow: /_api/
Expand All @@ -89,7 +89,7 @@ func TestSitemap(t *testing.T) {
WithURL("http://demo.test.fider.io:3000/sitemap.xml").
Execute(handlers.Sitemap())

bytes, _ := ioutil.ReadAll(response.Body)
bytes, _ := io.ReadAll(response.Body)
Expect(code).Equals(http.StatusOK)
Expect(string(bytes)).Equals(`<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url> <loc>http://demo.test.fider.io:3000</loc> </url></urlset>`)
}
Expand All @@ -112,7 +112,7 @@ func TestSitemap_WithPosts(t *testing.T) {
WithURL("http://demo.test.fider.io:3000/sitemap.xml").
Execute(handlers.Sitemap())

bytes, _ := ioutil.ReadAll(response.Body)
bytes, _ := io.ReadAll(response.Body)
Expect(code).Equals(http.StatusOK)
Expect(string(bytes)).Equals(`<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url> <loc>http://demo.test.fider.io:3000</loc> </url><url> <loc>http://demo.test.fider.io:3000/posts/1/my-new-idea-1</loc> </url><url> <loc>http://demo.test.fider.io:3000/posts/2/the-other-idea</loc> </url></urlset>`)
}
Expand Down
12 changes: 6 additions & 6 deletions app/handlers/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"image/color"
"image/png"
"io/ioutil"
"net/http"
"os"
"strings"
"time"

Expand All @@ -23,7 +23,7 @@ import (
"github.com/goenning/letteravatar"
)

//LetterAvatar returns a letter gravatar picture based on given name
// LetterAvatar returns a letter gravatar picture based on given name
func LetterAvatar() web.HandlerFunc {
return func(c *web.Context) error {
id := c.Param("id")
Expand Down Expand Up @@ -55,7 +55,7 @@ func LetterAvatar() web.HandlerFunc {
}
}

//Gravatar returns a gravatar picture of fallsback to letter avatar based on name
// Gravatar returns a gravatar picture of fallsback to letter avatar based on name
func Gravatar() web.HandlerFunc {
return func(c *web.Context) error {
id, err := c.ParamAsInt("id")
Expand Down Expand Up @@ -109,7 +109,7 @@ func Gravatar() web.HandlerFunc {
}
}

//Favicon returns the Fider favicon by given size
// Favicon returns the Fider favicon by given size
func Favicon() web.HandlerFunc {
return func(c *web.Context) error {
var (
Expand All @@ -128,7 +128,7 @@ func Favicon() web.HandlerFunc {
bytes = q.Result.Content
contentType = q.Result.ContentType
} else {
bytes, err = ioutil.ReadFile(env.Path("favicon.png"))
bytes, err = os.ReadFile(env.Path("favicon.png"))
contentType = "image/png"
if err != nil {
return c.Failure(err)
Expand Down Expand Up @@ -161,7 +161,7 @@ func Favicon() web.HandlerFunc {
}
}

//ViewUploadedImage returns any uploaded image by given ID and size
// ViewUploadedImage returns any uploaded image by given ID and size
func ViewUploadedImage() web.HandlerFunc {
return func(c *web.Context) error {
bkey := c.Param("bkey")
Expand Down
6 changes: 3 additions & 3 deletions app/handlers/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package handlers_test

import (
"context"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -81,7 +81,7 @@ func TestGravatarNotFound_LetterAvatarHandler(t *testing.T) {

expectedAvatar := []byte{137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 50, 0, 0, 0, 50, 8, 2, 0, 0, 0, 145, 93, 31, 230, 0, 0, 3, 6, 73, 68, 65, 84, 120, 156, 236, 152, 75, 79, 19, 81, 20, 128, 207, 204, 212, 210, 18, 90, 232, 211, 34, 196, 40, 6, 65, 129, 0, 209, 2, 11, 100, 97, 140, 113, 225, 2, 127, 3, 198, 196, 184, 55, 38, 38, 36, 198, 132, 168, 11, 149, 152, 24, 35, 97, 99, 220, 24, 23, 46, 140, 186, 49, 38, 242, 42, 20, 10, 72, 241, 149, 64, 75, 12, 125, 208, 86, 104, 7, 90, 103, 134, 206, 29, 211, 14, 25, 154, 66, 116, 46, 96, 101, 113, 191, 213, 225, 204, 153, 123, 191, 204, 185, 15, 82, 205, 197, 87, 157, 176, 255, 160, 255, 183, 192, 246, 16, 45, 28, 136, 22, 14, 68, 11, 7, 162, 133, 3, 209, 194, 129, 104, 225, 64, 180, 112, 32, 90, 56, 104, 212, 20, 117, 84, 158, 57, 119, 248, 172, 242, 103, 50, 157, 138, 164, 34, 19, 97, 143, 55, 54, 171, 36, 105, 138, 190, 209, 114, 93, 199, 20, 45, 115, 203, 15, 39, 31, 109, 29, 228, 90, 211, 213, 131, 197, 118, 1, 173, 223, 113, 223, 75, 163, 244, 30, 104, 89, 245, 150, 26, 243, 241, 188, 228, 133, 35, 231, 125, 9, 255, 125, 79, 111, 52, 21, 5, 0, 36, 161, 53, 97, 181, 177, 162, 1, 0, 94, 124, 127, 25, 74, 134, 243, 70, 232, 168, 108, 7, 0, 119, 120, 226, 175, 78, 216, 77, 124, 58, 211, 255, 192, 211, 251, 120, 250, 201, 251, 31, 31, 214, 81, 186, 170, 244, 104, 79, 251, 109, 147, 206, 36, 63, 29, 12, 12, 203, 65, 75, 121, 75, 222, 139, 173, 229, 173, 27, 53, 139, 67, 106, 38, 194, 211, 154, 138, 76, 143, 134, 220, 31, 23, 7, 251, 102, 250, 187, 71, 110, 241, 34, 111, 212, 26, 174, 52, 116, 201, 79, 63, 69, 103, 18, 60, 155, 145, 112, 56, 243, 94, 108, 203, 138, 38, 215, 147, 147, 145, 169, 189, 215, 202, 197, 23, 247, 189, 158, 127, 3, 0, 205, 246, 102, 171, 222, 42, 247, 209, 21, 116, 1, 192, 177, 178, 42, 139, 222, 162, 84, 154, 117, 166, 234, 178, 106, 0, 24, 13, 185, 213, 116, 112, 183, 59, 209, 21, 26, 5, 0, 138, 2, 167, 227, 148, 156, 217, 236, 163, 227, 180, 82, 230, 116, 56, 41, 74, 126, 170, 170, 131, 187, 213, 10, 174, 133, 228, 192, 166, 183, 201, 193, 92, 124, 62, 156, 92, 202, 106, 109, 246, 177, 181, 60, 19, 71, 127, 197, 190, 254, 252, 86, 8, 45, 36, 33, 94, 20, 0, 160, 180, 168, 84, 73, 14, 7, 71, 0, 160, 214, 92, 99, 212, 26, 0, 192, 168, 53, 156, 48, 215, 102, 242, 129, 17, 245, 35, 239, 246, 56, 213, 208, 153, 35, 70, 16, 121, 37, 35, 239, 53, 154, 162, 157, 217, 15, 230, 116, 56, 105, 42, 51, 203, 192, 226, 96, 129, 180, 76, 58, 19, 147, 157, 50, 198, 45, 43, 201, 80, 50, 60, 31, 247, 41, 189, 147, 247, 160, 63, 177, 16, 88, 11, 22, 72, 171, 222, 114, 82, 14, 230, 86, 230, 114, 243, 242, 210, 174, 183, 212, 217, 139, 109, 117, 214, 186, 220, 173, 240, 207, 181, 180, 140, 246, 82, 117, 39, 0, 172, 112, 241, 220, 91, 40, 187, 188, 92, 162, 132, 24, 154, 185, 220, 208, 197, 80, 52, 146, 208, 112, 1, 180, 40, 138, 170, 53, 215, 116, 183, 221, 172, 40, 57, 4, 0, 125, 222, 126, 36, 161, 220, 2, 150, 103, 189, 81, 47, 0, 52, 218, 50, 119, 209, 108, 236, 115, 156, 79, 96, 77, 161, 234, 78, 84, 184, 219, 209, 35, 73, 168, 228, 64, 9, 67, 51, 0, 32, 34, 241, 217, 151, 231, 158, 165, 201, 173, 149, 3, 129, 161, 38, 123, 227, 70, 140, 179, 216, 119, 162, 37, 239, 121, 0, 224, 69, 97, 44, 228, 126, 235, 127, 231, 79, 44, 108, 91, 57, 30, 158, 224, 210, 156, 78, 163, 227, 210, 220, 88, 120, 28, 87, 139, 82, 243, 179, 155, 81, 107, 80, 78, 38, 9, 128, 21, 88, 54, 123, 247, 253, 25, 123, 177, 189, 136, 209, 242, 162, 16, 73, 69, 112, 181, 84, 125, 45, 86, 88, 101, 133, 85, 220, 161, 119, 96, 163, 176, 79, 255, 59, 37, 90, 56, 16, 45, 28, 136, 22, 14, 68, 11, 7, 162, 133, 3, 209, 194, 129, 104, 225, 240, 59, 0, 0, 255, 255, 193, 108, 28, 164, 14, 189, 96, 131, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130}
Expect(code).Equals(http.StatusOK)
bytes, _ := ioutil.ReadAll(response.Body)
bytes, _ := io.ReadAll(response.Body)
Expect(bytes).Equals(expectedAvatar)
}

Expand All @@ -99,6 +99,6 @@ func TestUnknownUser_LetterAvatarHandler(t *testing.T) {

expectedAvatar := []byte{137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 50, 0, 0, 0, 50, 8, 2, 0, 0, 0, 145, 93, 31, 230, 0, 0, 2, 137, 73, 68, 65, 84, 120, 156, 236, 152, 75, 79, 19, 81, 20, 199, 255, 3, 51, 244, 65, 95, 80, 74, 43, 160, 149, 135, 36, 5, 177, 169, 137, 40, 42, 209, 152, 200, 74, 19, 87, 110, 248, 84, 126, 7, 227, 70, 23, 110, 140, 137, 154, 248, 32, 33, 152, 72, 20, 13, 6, 8, 62, 210, 74, 209, 218, 161, 239, 55, 237, 152, 67, 167, 37, 141, 36, 222, 139, 19, 202, 226, 254, 114, 51, 28, 78, 239, 220, 249, 245, 204, 205, 153, 73, 101, 237, 225, 61, 28, 63, 58, 218, 45, 112, 48, 66, 139, 7, 161, 197, 131, 208, 226, 65, 104, 241, 32, 180, 120, 16, 90, 60, 8, 45, 30, 132, 22, 15, 242, 127, 157, 237, 61, 133, 241, 243, 20, 124, 120, 141, 76, 162, 177, 164, 130, 145, 41, 156, 24, 134, 205, 65, 255, 22, 114, 248, 21, 198, 151, 143, 40, 230, 143, 74, 203, 100, 129, 219, 71, 129, 210, 165, 103, 44, 54, 92, 190, 5, 187, 107, 127, 142, 98, 130, 163, 23, 167, 39, 176, 244, 20, 234, 246, 145, 104, 253, 77, 232, 26, 57, 105, 26, 214, 222, 97, 251, 59, 180, 42, 122, 188, 152, 184, 8, 179, 21, 211, 115, 120, 254, 0, 187, 21, 150, 101, 12, 221, 91, 138, 9, 253, 39, 41, 136, 108, 96, 125, 25, 105, 21, 153, 36, 194, 235, 120, 255, 10, 245, 210, 14, 140, 48, 174, 100, 104, 181, 58, 26, 95, 178, 82, 106, 201, 199, 163, 248, 246, 153, 130, 114, 169, 29, 90, 165, 2, 149, 199, 238, 162, 157, 164, 254, 68, 244, 171, 158, 175, 238, 98, 229, 13, 215, 74, 70, 55, 136, 149, 5, 212, 106, 232, 148, 105, 39, 221, 184, 139, 241, 16, 172, 246, 67, 44, 99, 180, 86, 124, 11, 11, 143, 145, 138, 83, 236, 232, 165, 205, 62, 55, 143, 43, 183, 209, 235, 109, 171, 22, 128, 68, 12, 47, 31, 97, 241, 9, 194, 27, 168, 148, 41, 227, 25, 196, 236, 29, 186, 179, 204, 24, 221, 32, 154, 196, 34, 52, 58, 58, 49, 56, 138, 201, 25, 152, 45, 8, 206, 66, 141, 210, 230, 99, 128, 185, 90, 157, 50, 186, 204, 52, 90, 144, 244, 191, 154, 70, 71, 103, 31, 134, 198, 104, 72, 141, 124, 173, 74, 205, 98, 249, 197, 222, 92, 137, 90, 63, 27, 204, 213, 26, 11, 34, 112, 129, 130, 103, 247, 145, 207, 234, 73, 171, 77, 15, 202, 69, 58, 246, 15, 97, 242, 18, 5, 233, 29, 26, 77, 82, 170, 30, 40, 102, 198, 171, 49, 87, 43, 249, 91, 15, 134, 167, 244, 192, 210, 13, 127, 128, 130, 66, 22, 185, 52, 5, 212, 214, 247, 202, 118, 238, 42, 53, 207, 58, 146, 132, 209, 198, 41, 153, 29, 198, 171, 49, 87, 43, 22, 33, 51, 151, 7, 103, 130, 240, 249, 233, 185, 235, 242, 64, 81, 232, 163, 213, 183, 250, 156, 108, 18, 171, 75, 56, 59, 131, 190, 1, 220, 156, 167, 130, 85, 138, 176, 247, 232, 61, 34, 165, 226, 199, 38, 227, 213, 36, 142, 223, 183, 76, 22, 132, 174, 147, 83, 147, 82, 129, 156, 194, 107, 45, 211, 124, 126, 4, 166, 225, 116, 239, 103, 106, 53, 108, 109, 226, 211, 162, 126, 175, 13, 214, 170, 99, 181, 195, 225, 134, 44, 211, 27, 75, 34, 70, 155, 250, 64, 186, 157, 176, 57, 233, 205, 162, 84, 160, 54, 198, 252, 216, 169, 195, 223, 32, 242, 25, 26, 255, 36, 151, 162, 113, 88, 142, 233, 219, 169, 208, 226, 65, 104, 241, 32, 180, 120, 16, 90, 60, 8, 45, 30, 132, 22, 15, 66, 139, 135, 63, 1, 0, 0, 255, 255, 117, 91, 183, 108, 67, 255, 85, 68, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130}
Expect(code).Equals(http.StatusOK)
bytes, _ := ioutil.ReadAll(response.Body)
bytes, _ := io.ReadAll(response.Body)
Expect(bytes).Equals(expectedAvatar)
}
4 changes: 2 additions & 2 deletions app/middlewares/compress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package middlewares_test

import (
"compress/gzip"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -31,7 +31,7 @@ func TestCompress(t *testing.T) {
Execute(handler)

reader, _ := gzip.NewReader(response.Body)
bytes, _ := ioutil.ReadAll(reader)
bytes, _ := io.ReadAll(reader)
Expect(bytes).Equals([]byte(data))
Expect(status).Equals(http.StatusOK)
Expect(response.Header().Get("Vary")).Equals("Accept-Encoding")
Expand Down
8 changes: 4 additions & 4 deletions app/pkg/csv/csv_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package csv_test

import (
"io/ioutil"
"os"
"testing"
"time"

Expand All @@ -15,7 +15,7 @@ func TestExportPostsToCSV_Empty(t *testing.T) {
RegisterT(t)

posts := []*entity.Post{}
expected, err := ioutil.ReadFile("./testdata/empty.csv")
expected, err := os.ReadFile("./testdata/empty.csv")
Expect(err).IsNil()
actual, err := csv.FromPosts(posts)
Expect(err).IsNil()
Expand All @@ -29,7 +29,7 @@ func TestExportPostsToCSV_OnePost(t *testing.T) {
declinedPost,
}

expected, err := ioutil.ReadFile("./testdata/one-post.csv")
expected, err := os.ReadFile("./testdata/one-post.csv")
Expect(err).IsNil()
actual, err := csv.FromPosts(posts)
Expect(err).IsNil()
Expand All @@ -45,7 +45,7 @@ func TestExportPostsToCSV_MorePosts(t *testing.T) {
duplicatePost,
}

expected, err := ioutil.ReadFile("./testdata/more-posts.csv")
expected, err := os.ReadFile("./testdata/more-posts.csv")
Expect(err).IsNil()
actual, err := csv.FromPosts(posts)
Expect(err).IsNil()
Expand Down
Loading

0 comments on commit cce8efa

Please sign in to comment.