Skip to content

Commit

Permalink
Adds tests that exercise linker.
Browse files Browse the repository at this point in the history
Adds tests that exercise linker, related to upstream changes:
a0a82e1

[#105470778]
  • Loading branch information
pivotal committed Oct 14, 2015
1 parent dc67a53 commit 3a6deb1
Show file tree
Hide file tree
Showing 17 changed files with 187 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions cf_spec/fixtures/go1.4.2_app_using_ldflags/src/go_app/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Rasheed Abdul-Aziz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: go-online
10 changes: 10 additions & 0 deletions cf_spec/fixtures/go1.4.2_app_using_ldflags/src/go_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
go-online
=========

Sample go web app using the GoLang example: http://golang.org/doc/articles/wiki/final.go

to run
======

$ go build site.go
$ PORT=3000 ./site
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
env:
GO_LINKER_SYMBOL: main.linker_flag
GO_LINKER_VALUE: flag_linked
23 changes: 23 additions & 0 deletions cf_spec/fixtures/go1.4.2_app_using_ldflags/src/go_app/site.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
"net/http"
"os"
)

var linker_flag string

func main() {
http.HandleFunc("/", hello)
fmt.Println("listening...")
err := http.ListenAndServe(":"+os.Getenv("PORT"), nil)
if err != nil {
panic(err)
}
}

func hello(res http.ResponseWriter, req *http.Request) {
fmt.Fprintln(res, linker_flag)
fmt.Fprintln(res, "done")
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions cf_spec/fixtures/go1.5_app_using_ldflags/src/go_app/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Rasheed Abdul-Aziz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: go-online
10 changes: 10 additions & 0 deletions cf_spec/fixtures/go1.5_app_using_ldflags/src/go_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
go-online
=========

Sample go web app using the GoLang example: http://golang.org/doc/articles/wiki/final.go

to run
======

$ go build site.go
$ PORT=3000 ./site
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
env:
GO_LINKER_SYMBOL: main.linker_flag
GO_LINKER_VALUE: flag_linked
23 changes: 23 additions & 0 deletions cf_spec/fixtures/go1.5_app_using_ldflags/src/go_app/site.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
"net/http"
"os"
)

var linker_flag string

func main() {
http.HandleFunc("/", hello)
fmt.Println("listening...")
err := http.ListenAndServe(":"+os.Getenv("PORT"), nil)
if err != nil {
panic(err)
}
}

func hello(res http.ResponseWriter, req *http.Request) {
fmt.Fprintln(res, linker_flag)
fmt.Fprintln(res, "done")
}
45 changes: 45 additions & 0 deletions cf_spec/integration/deploy_a_go_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@
expect(app.host).not_to have_internet_traffic
end
end

context 'a go app using ldflags' do
context 'with version 1.5 or greater' do
let(:app_name) { 'go1.5_app_using_ldflags/src/go_app' }

specify do
expect(app).to be_running
browser.visit_path('/')
expect(browser).to have_body('flag_linked')
expect(app.host).not_to have_internet_traffic
end
end
context 'with version 1.4.2 or less' do
let(:app_name) { 'go1.4.2_app_using_ldflags/src/go_app' }

specify do
expect(app).to be_running
browser.visit_path('/')
expect(browser).to have_body('flag_linked')
expect(app.host).not_to have_internet_traffic
end
end
end

end

context 'without cached buildpack dependencies', :uncached do
Expand Down Expand Up @@ -138,6 +162,27 @@
expect(browser).to have_body('hello, heroku')
end
end

context 'a go app using ldflags' do
context 'with version 1.5 or greater' do
let(:app_name) { 'go1.5_app_using_ldflags/src/go_app' }

specify do
expect(app).to be_running
browser.visit_path('/')
expect(browser).to have_body('flag_linked')
end
end
context 'with version 1.4.2 or less' do
let(:app_name) { 'go1.4.2_app_using_ldflags/src/go_app' }

specify do
expect(app).to be_running
browser.visit_path('/')
expect(browser).to have_body('flag_linked')
end
end
end
end

context 'deprecated heroku example' do
Expand Down

0 comments on commit 3a6deb1

Please sign in to comment.