@@ -2,7 +2,6 @@ package finalize_test
22
33import (
44 "errors"
5- "io/ioutil"
65 "os"
76 "path/filepath"
87 "regexp"
@@ -37,10 +36,10 @@ var _ = Describe("Compile", func() {
3736 )
3837
3938 BeforeEach (func () {
40- buildDir , err = ioutil . TempDir ("" , "staticfile-buildpack.build." )
39+ buildDir , err = os . MkdirTemp ("" , "staticfile-buildpack.build." )
4140 Expect (err ).To (BeNil ())
4241
43- depDir , err = ioutil . TempDir ("" , "staticfile-buildpack.depDir." )
42+ depDir , err = os . MkdirTemp ("" , "staticfile-buildpack.depDir." )
4443 Expect (err ).To (BeNil ())
4544
4645 buffer = new (bytes.Buffer )
@@ -75,7 +74,7 @@ var _ = Describe("Compile", func() {
7574 err = finalizer .WriteStartupFiles ()
7675 Expect (err ).To (BeNil ())
7776
78- contents , err := ioutil .ReadFile (filepath .Join (depDir , "profile.d" , "staticfile.sh" ))
77+ contents , err := os .ReadFile (filepath .Join (depDir , "profile.d" , "staticfile.sh" ))
7978 Expect (err ).To (BeNil ())
8079 Expect (string (contents )).To (ContainSubstring ("export LD_LIBRARY_PATH=$APP_ROOT/nginx/lib:$LD_LIBRARY_PATH" ))
8180 })
@@ -84,7 +83,7 @@ var _ = Describe("Compile", func() {
8483 err = finalizer .WriteStartupFiles ()
8584 Expect (err ).To (BeNil ())
8685
87- contents , err := ioutil .ReadFile (filepath .Join (buildDir , "start_logging.sh" ))
86+ contents , err := os .ReadFile (filepath .Join (buildDir , "start_logging.sh" ))
8887 Expect (err ).To (BeNil ())
8988 Expect (string (contents )).To (Equal ("\n cat < $APP_ROOT/nginx/logs/access.log &\n (>&2 cat) < $APP_ROOT/nginx/logs/error.log &\n " ))
9089 })
@@ -102,7 +101,7 @@ var _ = Describe("Compile", func() {
102101 err = finalizer .WriteStartupFiles ()
103102 Expect (err ).To (BeNil ())
104103
105- contents , err := ioutil .ReadFile (filepath .Join (buildDir , "boot.sh" ))
104+ contents , err := os .ReadFile (filepath .Join (buildDir , "boot.sh" ))
106105 Expect (err ).To (BeNil ())
107106 Expect (string (contents )).To (Equal ("#!/bin/sh\n set -ex\n $APP_ROOT/start_logging.sh\n nginx -p $APP_ROOT/nginx -c $APP_ROOT/nginx/conf/nginx.conf\n " ))
108107 })
@@ -350,7 +349,7 @@ var _ = Describe("Compile", func() {
350349
351350 Context ("Staticfile.auth is present" , func () {
352351 BeforeEach (func () {
353- err = ioutil .WriteFile (filepath .Join (buildDir , "Staticfile.auth" ), []byte ("some credentials" ), 0644 )
352+ err = os .WriteFile (filepath .Join (buildDir , "Staticfile.auth" ), []byte ("some credentials" ), 0644 )
354353 Expect (err ).To (BeNil ())
355354 })
356355 JustBeforeEach (func () {
@@ -428,7 +427,7 @@ var _ = Describe("Compile", func() {
428427
429428 Context ("the directory exists but is actually a file" , func () {
430429 BeforeEach (func () {
431- ioutil .WriteFile (filepath .Join (buildDir , "actually_a_file" ), []byte ("xxx" ), 0644 )
430+ os .WriteFile (filepath .Join (buildDir , "actually_a_file" ), []byte ("xxx" ), 0644 )
432431 staticfile .RootDir = "actually_a_file"
433432 })
434433
@@ -544,13 +543,13 @@ var _ = Describe("Compile", func() {
544543 err = os .MkdirAll (filepath .Join (buildDir , "public" ), 0755 )
545544 Expect (err ).To (BeNil ())
546545
547- err = ioutil .WriteFile (filepath .Join (buildDir , "public" , "nginx.conf" ), []byte ("nginx configuration" ), 0644 )
546+ err = os .WriteFile (filepath .Join (buildDir , "public" , "nginx.conf" ), []byte ("nginx configuration" ), 0644 )
548547 Expect (err ).To (BeNil ())
549548 })
550549
551550 It ("uses the custom configuration" , func () {
552551 Expect (filepath .Join (buildDir , "nginx" , "conf" , "nginx.conf" )).To (BeARegularFile ())
553- data , err = ioutil .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "nginx.conf" ))
552+ data , err = os .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "nginx.conf" ))
554553 Expect (err ).To (BeNil ())
555554 Expect (data ).To (Equal ([]byte ("nginx configuration" )))
556555 })
@@ -568,7 +567,7 @@ var _ = Describe("Compile", func() {
568567 leadCloseWsp := regexp .MustCompile (`(?m)^\s+` )
569568 stripStartWsp := func (inp string ) string { return leadCloseWsp .ReplaceAllString (inp , "" ) }
570569 readNginxConfAndStrip := func () string {
571- data , err = ioutil .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "nginx.conf" ))
570+ data , err = os .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "nginx.conf" ))
572571 Expect (err ).To (BeNil ())
573572 return stripStartWsp (string (data ))
574573 }
@@ -820,7 +819,7 @@ var _ = Describe("Compile", func() {
820819 Context ("there is a Staticfile.auth" , func () {
821820 BeforeEach (func () {
822821 staticfile .BasicAuth = true
823- err = ioutil .WriteFile (filepath .Join (buildDir , "Staticfile.auth" ), []byte ("authentication info" ), 0644 )
822+ err = os .WriteFile (filepath .Join (buildDir , "Staticfile.auth" ), []byte ("authentication info" ), 0644 )
824823 Expect (err ).To (BeNil ())
825824 })
826825
@@ -830,7 +829,7 @@ var _ = Describe("Compile", func() {
830829 })
831830
832831 It ("copies the Staticfile.auth to .htpasswd" , func () {
833- data , err = ioutil .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , ".htpasswd" ))
832+ data , err = os .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , ".htpasswd" ))
834833 Expect (err ).To (BeNil ())
835834 Expect (string (data )).To (Equal ("authentication info" ))
836835 })
@@ -856,20 +855,20 @@ var _ = Describe("Compile", func() {
856855 err = os .MkdirAll (filepath .Join (buildDir , "public" ), 0755 )
857856 Expect (err ).To (BeNil ())
858857
859- err = ioutil .WriteFile (filepath .Join (buildDir , "public" , "mime.types" ), []byte ("mime types info" ), 0644 )
858+ err = os .WriteFile (filepath .Join (buildDir , "public" , "mime.types" ), []byte ("mime types info" ), 0644 )
860859 Expect (err ).To (BeNil ())
861860 })
862861
863862 It ("uses the custom configuration" , func () {
864- data , err = ioutil .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "mime.types" ))
863+ data , err = os .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "mime.types" ))
865864 Expect (err ).To (BeNil ())
866865 Expect (data ).To (Equal ([]byte ("mime types info" )))
867866 })
868867 })
869868
870869 Context ("custom mime.types does NOT exist" , func () {
871870 It ("uses the provided mime.types" , func () {
872- data , err = ioutil .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "mime.types" ))
871+ data , err = os .ReadFile (filepath .Join (buildDir , "nginx" , "conf" , "mime.types" ))
873872 Expect (err ).To (BeNil ())
874873 Expect (string (data )).To (Equal (finalize .MimeTypes ))
875874 })
@@ -888,14 +887,14 @@ var _ = Describe("Compile", func() {
888887 buildDirFiles = []string {"Staticfile" , "Staticfile.auth" , "manifest.yml" , ".profile" , "stackato.yml" }
889888
890889 for _ , file := range buildDirFiles {
891- err = ioutil .WriteFile (filepath .Join (buildDir , file ), []byte (file + "contents" ), 0644 )
890+ err = os .WriteFile (filepath .Join (buildDir , file ), []byte (file + "contents" ), 0644 )
892891 Expect (err ).To (BeNil ())
893892 }
894893
895894 appRootFiles = []string {".hidden.html" , "index.html" }
896895
897896 for _ , file := range appRootFiles {
898- err = ioutil .WriteFile (filepath .Join (appRootDir , file ), []byte (file + "contents" ), 0644 )
897+ err = os .WriteFile (filepath .Join (appRootDir , file ), []byte (file + "contents" ), 0644 )
899898 Expect (err ).To (BeNil ())
900899 }
901900
@@ -920,7 +919,7 @@ var _ = Describe("Compile", func() {
920919 err = os .MkdirAll (appRootDir , 0755 )
921920 Expect (err ).To (BeNil ())
922921
923- err = ioutil .WriteFile (filepath .Join (appRootDir , "index2.html" ), []byte ("html contents" ), 0644 )
922+ err = os .WriteFile (filepath .Join (appRootDir , "index2.html" ), []byte ("html contents" ), 0644 )
924923 })
925924
926925 It ("doesn't copy any files" , func () {
@@ -944,7 +943,7 @@ var _ = Describe("Compile", func() {
944943 Context ("host dotfiles is set" , func () {
945944 BeforeEach (func () {
946945 staticfile .HostDotFiles = true
947- appRootDir , err = ioutil . TempDir ("" , "staticfile-buildpack.app_root." )
946+ appRootDir , err = os . MkdirTemp ("" , "staticfile-buildpack.app_root." )
948947 Expect (err ).To (BeNil ())
949948 })
950949
@@ -979,7 +978,7 @@ var _ = Describe("Compile", func() {
979978 Context ("and <buildDir>/public exists" , func () {
980979 BeforeEach (func () {
981980 Expect (os .Mkdir (filepath .Join (buildDir , "public" ), 0755 )).To (Succeed ())
982- Expect (ioutil .WriteFile (filepath .Join (buildDir , "public" , "orig.html" ), []byte ("html contents" ), 0644 )).To (Succeed ())
981+ Expect (os .WriteFile (filepath .Join (buildDir , "public" , "orig.html" ), []byte ("html contents" ), 0644 )).To (Succeed ())
983982 })
984983 It ("overrides <buildDir>/public" , func () {
985984 Expect (filepath .Join (buildDir , "public" , "orig.html" )).ToNot (BeAnExistingFile ())
0 commit comments