blob: 26aff3a534ae4e3d74c9bdf23f0df1ae6c372119 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
import (
func TestQueue(t *testing.T) {
buildID := "foo"
filename := fmt.Sprintf("%s.debug", buildID)
tmpFile, err := os.CreateTemp("", filename)
if err != nil {
t.Fatalf("Failed to create tempfile: %v", err)
defer os.Remove(tmpFile.Name())
binaryFileRef := elflib.NewBinaryFileRef(tmpFile.Name(), buildID)
c, err := queue([]elflib.BinaryFileRef{binaryFileRef})
if err != nil {
t.Fatalf("Unexpected error from queue(): %s", err)
var jobs []job
for j := range c {
jobs = append(jobs, j)
if len(jobs) != 2 {
t.Fatalf("Expected queue() to produce 2 jobs but got %d", len(jobs))
// Relative order of zxdb and debuginfod jobs doesn't actually matter, but
// ignoring order would introduce too much complexity here.
if !strings.HasPrefix(jobs[0].path, zxdbNamespace) {
t.Errorf("Expected queue() to queue a zxdb upload job first but found: %+v", jobs[0])
if !strings.HasPrefix(jobs[1].path, debuginfodNamespace) {
t.Errorf("Expected queue() to queue a debuginfod upload job last but found: %+v", jobs[1])