mirror of
https://github.com/containers/podman.git
synced 2025-11-02 23:39:52 +08:00
Add --tz flag to create, run
--tz flag sets timezone inside container Can be set to IANA timezone as well as `local` to match host machine Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
@ -1047,4 +1047,29 @@ USER mail`
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(strings.Contains(session.OutputToString(), groupName)).To(BeTrue())
|
||||
})
|
||||
|
||||
It("podman run --tz", func() {
|
||||
session := podmanTest.Podman([]string{"run", "--tz", "foo", "--rm", ALPINE, "date"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--tz", "America", "--rm", ALPINE, "date"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--tz", "Pacific/Honolulu", "--rm", ALPINE, "date", "+'%H %Z'"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("HST"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--tz", "local", "--rm", ALPINE, "date", "+'%H %Z'"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
t := time.Now()
|
||||
z, _ := t.Zone()
|
||||
h := strconv.Itoa(t.Hour())
|
||||
Expect(session.OutputToString()).To(ContainSubstring(z))
|
||||
Expect(session.OutputToString()).To(ContainSubstring(h))
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user